如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
<!-- --> <html> <title></title> <body> <div id="app"> {{fullName}} </div> </body> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script> var vm = new Vue({ el:'#app', data:{ firstName:'Dell', lastName:'Lee', // fullName:"Dell Lee" }, //计算属性:有缓存机制,只要依赖的没有改变,则使用缓存数据 computed:{ fullName:{ get:function(){ return this.firstName+ " "+this.lastName }, set:function (value){ var arr = value.split(" "); this.firstName = arr[0]; this.lastName = arr[1]; } } } }) </script> </html>