您的位置:首页 > Web前端 > Vue.js

Vue学习:计算属性,方法,侦听器

2018-12-15 17:33 661 查看

计算属性:
computed 优势:内置缓存 依赖属性未发生改变时 页面渲染计算属性不执行

computed:{
fullName:function(){
return : this.firstName + ' ' + this.lastName
}
}
{{fullName}}

方法:
methods 页面数据重新渲染时方法将重新执行()

methods: {
fullName:function(){
return : this.firstName + ' ' + this.lastName
}
}
{{fullName}}

侦听器:
watch内置缓存 代码将会复杂化

watch: {
firstName: function(){
this.fullName=   this.firstName + ' ' + this.lastName
}
lastName: function(){
this.fullName=   this.firstName + ' ' + this.lastName
}
}
{{fullName}}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: