vue3 强制刷新 forceUpdate
使用场景: vue2文件转vue3表单props select option修改打印有值,dom不更新
最终解决:
<script setup>
import { getCurrentInstance, ComponentInternalInstance } from 'vue';
setup(){
// ctx 得到普通对象
// proxy得到响应式对象
// 推荐使用proxyconst { proxy } = getCurrentInstance() as ComponentInternalInstanceproxy!.$forceUpdate()
}
</script>
推荐尝试无效
使用that.$forceUpdate() 本地运行有效打包后无效
猜测that可能被编译了
添加vite.config配置build
minify: false
尝试无效