You will always have the option to print the value of Vue property using double curly bracket like {{ curly }}
. But if you want to print plain text you can also use v-text
directive. This accepts only string.
<span v-text="name"></span> data:{ name : "Santanu Bera" }
This will print Santanu Bera
You can also pass integer or float value and even object or array datatype. But everything will be rendered as a string. So if you use any HTML tag inside the string, it won't be rendered.
<span v-text="name"></span> data:{ name : { first : 'Santanu', last : "Bera" } }
This will give the output as { "first": "Santanu", "last": "Bera" }
<span v-text="name"></span> data:{ name : ['Santanu', 'Bera'] }
This will give the output as [ "Santanu", "Bera" ]
<span v-text="name"></span> data:{ name : "<span>Hello</span>" }
This will give the output as <span>Hello</span>
So, if you see there's no great advantage of using v-text
directive. It's just an alternative way for {{ curly }}
syntax. You can also use inline JS expression inside the v-text
just like you can do in {{ curly }}
way.