0👍
✅
This is probably a bug in <script setup>
, as that same code works in setup()
.
A workaround is to switch to setup()
if you need to use onUpdated()
:
<script lang="ts">
import { h, ref, onUpdated } from 'vue'
export default {
setup(props, { expose }) {
const open = ref(false)
const toggle = () => {
open.value = !open.value
}
expose({ toggle })
onUpdated(() => {
console.log("Updated")
})
const render = () => open.value ? h('DIV', "Child Component") : null
return render
}
}
</script>
Source:stackexchange.com