vue3中使用$forceUpdate
时间:2024-03-30 07:30:54 来源:网络cs 作者:纳雷武 栏目:培训机构 阅读:
在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>
参考:https://blog.csdn.net/qq_43291759?type=blog
本文链接:https://www.kjpai.cn/news/2024-03-30/150647.html,文章来源:网络cs,作者:纳雷武,版权归作者所有,如需转载请注明来源和作者,否则将追究法律责任!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
上一篇:reverse函数(C++)
下一篇:返回列表