一、计算属性
1、计算属性的基本使用(四种实现方法)
<code>
<title>计算属性的基本使用/<title>
{{firstName+' '+lastName}}
{{firstName}} {{lastName}}
{{getFullName()}}
{{fullName}}
/<code>
2、计算属性的复杂操作
<code>
<title>计算属性的复杂操作/<title>
总价格:{{totalPrice}}
/<code>
3、计算属性的setter和getter
<code>
<title>计算属性的setter和getter/<title>
{{fullName}}
/<code>
4、计算属性computed和methods的对比
<code>
<title>计算属性和methods的对比/<title>
{{firstName}} {{lastName}}
{{fullName()}}
{{getFullName}}
/<code>
二、相关ES6语法
1、let/var(块级作用域)
★ ES5中的var是没有块级作用域的,ES6中的let是有块级作用域的
<code>
<title>块级作用域/<title>
<button>按钮1/<button>
<button>按钮2/<button>
<button>按钮3/<button>
<button>按钮4/<button>
<button>按钮5/<button>
v/<code>
2、const的使用
★ 主要的作用是将某个变量修饰为常量,在ES6开发中,优先使用const,只有需要改变某一个标识符的时候采用let
<code>
<title>const的使用/<title>
/<code>
3、对象的增强写法
★ ES6中,对对象字面量进行了很多增强
<code>
<title>对象字面量的增强写法/<title>
/<code>
閱讀更多 想做大牛的程序猿 的文章