Vue计算属性computed

1. computed  写法说明

基本用法
computed: {
  fullName: {
     this.firstName + this.lastName  
  }  
}

完整写法 computed: { fullName: {
set: function (newValue) {console.log(nweValue)}//一般没有set方法, 只读属性 get: function () { reture this.name} } }
控制台修改fullName
Vue.fullName = "renhao" //set 的newVlaue = 'renhao' 简化写法(平常使用) computed: { fullName: { function () { reture
this.name} } }

2.computed  有缓存,多次调用只执行一次,methods 没有缓存,调用几次执行几次

原文地址:https://www.cnblogs.com/jidanbufan/p/13899707.html