vuejs-challenges
vuejs-challenges copied to clipboard
11 - 下一次DOM更新
<script setup>
import { ref, nextTick } from "vue"
const count = ref(0)
function increment() {
count.value++
nextTick(() => {
// 访问更新后的 DOM
console.log(+document.getElementById("counter").textContent === 1)
})
}
</script>
<template>
<button id="counter" @click="increment">
{{ count }}
</button>
</template>