zl程序教程

您现在的位置是:首页 >  前端

当前栏目

Vue3基础(22)___vue3中使用$forceUpdate

Vue3基础 22 ___ 使用
2023-09-27 14:22:48 时间

在vue2中直接

this.$forceUpdate()

在vue3中直接

import { getCurrentInstance } from "vue";
setup(){
//解构赋值 设置别名that  也可不写  :that  直接ctx
//ctx 得到普通对象
//proxy得到响应式对象
// 推荐使用proxy
  	let {ctx:that, proxy} = getCurrentInstance()
	that.$forceUpdate()
}