var vm = new Vue({
data: { a: 1 },
computed: {
// 仅读取,值只须为函数
aDouble: function () {
console.log(this.a);
return this.a * 2
},
// 读取和设置
aPlus: {
get: function () {
return this.a + 1
},
set: function (v) {
this.a = v - 1
}
}
},
methods:{
show(){
this.a += 1;
}
}
});
vm.aPlus;
vm.aPlus = 3;