Vue's template syntax (3-3)

Vue's template syntax

Assignment, there are three commonly used, but you must know the difference between them.
Knowledge points:

  1. String splicing
  2. v-text
  3. v-html

As for v-text, it directly assigns the bound data.
For v-html, if the value has a tag, the effect of the tag will be displayed.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='./vue.js'></script>
</head>
<body>
    <div id="app">
        {
   
   {name + ' LEE'}}
        <div v-text="name + ' LEE'"></div>
        <div v-html="name + ' LWW'"></div>
    </div>    
    <script>
        var vm = new Vue({
     
     
            el: "#app",
            data: {
     
     
                name: "Dell"
                // name: "<h1>Dell</h1>"
            }
        })
    </script>
</body>
</html>

Guess you like

Origin blog.csdn.net/weixin_45647118/article/details/113830615
Recommended