Skip to content

11 - Next DOM update flush #2887

Closed
Closed
@filimonich

Description

@filimonich
<script setup>
import { ref, nextTick } from "vue"

const count = ref(0)
const counter = ref(null)

async function increment() {
  count.value++

  /**
   * DOM is not yet updated, how can we make sure that the DOM gets updated
   * Make the output be true
  */
  await nextTick()
  console.log(+counter.value.textContent === count.value)
}
</script>

<template>
  <button ref="counter" @click="increment">
    {{ count }}
  </button>
</template>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions