在vue3中强制更新dom使用 forceUpdate()

9,481 阅读1分钟

vue3+ts

import { getCurrentInstance, ComponentInternalInstance } from 'vue'
const update = getCurrentInstance() as ComponentInternalInstance | null
---------------------------
  //强制更新dom
update!.proxy!.$forceUpdate()
  
  //如果觉得麻烦ts类型可为any