作用:给元素赋值

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
    7. <title>指令之v-text和v-html</title>
    8. </head>
    9. <body>
    10. <div id='app'>
    11. <h1>{{ msg }}</h1>
    12. <h2 v-text='msg'></h2>
    13. <div v-html='htmlMsg'></div>
    14. </div>
    15. <script src="./vue.js"></script>
    16. <script>
    17. // {{}}和v-text的作用是一样的 都是插入值 直接渲染 innerText
    18. // v-html既能插入值 又能插入标签 innerHTML
    19. new Vue({
    20. el:'#app',
    21. data:{
    22. msg:"插入标签",
    23. htmlMsg:'<h3>ecithy</h3>'
    24. }
    25. })
    26. </script>
    27. </body>
    28. </html>