Text Interpolation
Text interpolation is a way to show a value inside page text. Double curly braces mark the value in the markup.
Show a name
This line shows the name value.
<h1>Hello, {{ name }}!</h1>Show a number
This line shows the count value.
<p>Count: {{ count }}</p>Example
<script setup>
const name = 'Maya'
const count = 3
</script>
<template>
<div>
<h1>Hello, {{ name }}!</h1>
<p>Count: {{ count }}</p>
</div>
</template>Key points
- Text interpolation is a way to show a value inside page text.
- Double curly braces look like {{ }}.
- Vue replaces the braces with the value when the page shows.
- The value comes from a plain const in the script block.
In this example, the script block holds two plain consts. The const name holds Maya. The const count holds 3. The heading shows the name with double curly braces. The line shows the count with double curly braces.
Note
Interpolation shows a value as plain text.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does {{ name }} show on the page?