v-text

Sets an element's textContent from an expression.

Since Vue 3.0 Spec ↗

Syntax

v-text="expression"

Parameters

NameTypeRequiredDescription
expression any No Value rendered as escaped text content.

Returns

directive — Sets the element's textContent.

Examples

<script setup lang="ts">
import { ref } from 'vue';
const msg = ref('Hello <world>');
</script>

<template>
  <span v-text="msg"></span>
  <!-- equivalent to: <span>{{ msg }}</span> -->
</template>

Notes

v-text replaces the element's entire text content and escapes HTML, making it equivalent to mustache interpolation. Mustache `{{ }}` is usually preferred for readability; v-text is handy when you must avoid an uncompiled-template flash without v-cloak.