Search code examples
javascripthtmlvue.jsdommustache

<p v-text="foo"> vs <p>{{foo}}</p> in vue?


what is the difference between <p v-text="foo"> and <p>{{ foo }}</p> in vue?

I know {{ foo }} is some DOM thingy, but they achieve the same function, so is <p v-text="foo"> also doing something to DOM?


Solution

  • They do exactly the same thing. From the v-text docs:

    Internally, {{ Mustache }} interpolations are also compiled as a v-text directive on a textNode.

    With either one, the compiler will turn the template markup into the same node.