1.官方有了{{data}}绑定数据了,为啥还要v-text 因为网络问题,可以我们会卡到看“{{}}”,很尴尬吧!!! => 因此推荐用v-text
2. v-html是啥? 能吃吗 , v-html和innerHTML一样.
1 <!DOCTYPE html>
2 <html lang="en">
3
4 <head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <meta http-equiv="X-UA-Compatible" content="ie=edge">
8 <title>Document</title>
9 <!-- Step1.对于vue,可以用cdn -->
10 <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js"></script>
11 <style>
12 #app div{
13 padding: 2%;
14 margin-bottom: 1%;
15 border-bottom: 1px solid #ddd;
16 background-color: blanchedalmond;
17 }
18 </style>
19 </head>
20
21 <body>
22
23
24 <div id="app">
25
26 <!-- 文本显示 -->
27 <div>{{ message }}</div>
28 <div v-text="message"></div>
29
30
31 <!-- html标签渲染 -->
32 <div v-html="htmlMsg"></div>
33
34 </div>
35
36 <script type="text/javascript">
37 var app = new Vue({
38 el: '#app',
39 data: {
40 message: 'Hei!!!',
41 htmlMsg: '<p>怎么了,输出了html标签!</p>'
42 }
43 })
44 </script>
45 </body>
46
47 </html>