Back to Developer Roadmap

v-once

src/data/roadmaps/vue/content/[email protected]

4.0559 B
Original Source

v-once

The v-once directive makes an HTML element render only once, skipping every future update.

Example

html
<script setup>
  import { ref } from 'vue';
  const input = ref("Some Text");
</script>

<template>
  <input v-model="input">
  <p v-once>{{ input }}</p>
</template>

In this example the p element will not change its text even if the input variable is changed through the input element.

Visit the following resources to learn more: