How to forceUpdate in setup in vue3?
When use Options Api, I can use this.$forceUpdate() to forceUpdate.How to do the same in setup function in vue3?
How to forceUpdate in setup in vue3?
When use Options Api, I can use this.$forceUpdate() to forceUpdate.How to do the same in setup function in vue3?
<script lang="ts">
import { defineComponent, getCurrentInstance } from "vue";
export default defineComponent({
setup() {
const { ctx: _this }: any = getCurrentInstance()
let arr = [1]
const handleClick = () => {
arr.push(2)
_this.$forceUpdate()
}
return {
arr
};
},
});
</script>
<template>
<div>
<div>{{arr}}</div>
<button @click="handleClick">add</button>
</div>
</template>
done