vue数据绑定
方法1:重新赋值
this.userInfo = {
// 将原来的userInfo 通过扩展运算法复制到新的对象里面
...this.userInfo,
// 添加新属性
officialAccount: '前端有的玩'
}
方法2: vue.set
Vue.set(this.userInfo,'officialAccount', '前端有的玩')
性能优化
Object.freeze:当数据只做展示 不需要监听数据变化时
const data = Array(1000)
.fill(1)
.map((item, index) => {
// 虽然不能冻结整个数组,但是可以冻结每一项数据
return Object.freeze({
date: '2020-07-11',
name: `子君${index}`,
address: '大西安'
})
})
this.tableData = this.tableData.concat(data)。