vue3中使用$forceUpdate
•
前端
在vue2中直接
this.$forceUpdate()
在vue3中直接
import { getCurrentInstance } from "vue";
setup(){
//解构赋值 设置别名that 也可不写 :that 直接ctx
//ctx 得到普通对象
//proxy得到响应式对象
// 推荐使用proxy
let {ctx:that, proxy} = getCurrentInstance()
that.$forceUpdate()
}
在vue3+TS中直接
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
setup(){
// ctx 得到普通对象
// proxy得到响应式对象
// 推荐使用proxy
const { proxy } = getCurrentInstance() as ComponentInternalInstance
proxy!.$forceUpdate()
}
参考:https://blog.csdn.net/qq_43291759?type=blog
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/65d9a9556d.html
