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中直接
<script setup>
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
setup(){
// ctx 得到普通对象
// proxy得到响应式对象
// 推荐使用proxy
const { proxy } = getCurrentInstance() as ComponentInternalInstance
proxy!.$forceUpdate()
}
</script>
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)