首页 前端知识 vue中强制更新视图

vue中强制更新视图

2025-03-02 13:03:07 前端知识 前端哥 57 431 我要收藏

vue3 中强制更新视图 方式

通过 $forceUpdate 与 vue2 相似

import {getCurrentInstance} from 'vue'
 
const internalInstance = getCurrentInstance()
//操作数据后更新视图
internalInstance.ctx.$forceUpdate()

通过 key 值改变更新

<compName :key="key" />

const onChangeKey = ()=> {
    key.value = Date.now();
}
转载请注明出处或者链接地址:https://www.qianduange.cn//article/22236.html
标签
评论
发布的文章

算法002——复写零

2025-03-02 13:03:05

github上传代码(自用)

2025-03-02 13:03:59

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!