vue开发的过程中我们时常会遇到 数据更新和视图更新 不匹配的问题。简单点说就是vue没有监测到这一块儿的数据变化。
简单的解决方法有几种
vue2 中
Vue.set( target, key, value ) 中有三个参数给我们
this.$set(this.student,"age", 24)
data(){
return {
list: [3,2,1]
}
}
···
this.list = [1,2,3]
this.$forceUpdate()
vue3中
import { getCurrentInstance } from "vue";
setup(){
let {ctx:that} = getCurrentInstance()
that.$forceUpdate()
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)