如果真的很需要在vue3中使用forceUpdate,同时又想使用 <script lang="ts" setup>的写法,那么可以这样写:
<template> <button @click="handleClick">按钮</button> </template> <style scoped lang="less"></style> <script lang="ts" setup> import { getCurrentInstance } from "vue";const { proxy: { $forceUpdate }, }: any = getCurrentInstance(); function handleClick() { $forceUpdate(); console.log($forceUpdate, "bingo!"); } </script> 标签:bingo,vue3,any,getCurrentInstance,使用,方法,forceUpdate From: https://www.cnblogs.com/shidawang/p/17079923.html