v-text、v-html、{{}}中均可以跟上js表達式,而不單單是變量:javascript
<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="./vue.js"></script> <!-- <script src="http://cdn.staticfile.org/vue/2.6.10/vue.common.dev.js"></script> --> </head> <body> <div id="app"> <!-- v-text="name"和{{age}}均可以顯示變量,v-html能夠渲染出html標籤 --> <div v-text="name + ' 666'"></div> <div v-html="html + ' 嘿嘿嘿'"></div> <div>{{age + '呵呵呵'}}</div> </div> <script type="text/javascript"> var vm = new Vue({ el: "#app", data: { name: "<b>阿三</b>", age: "<b>18</b>", html: "<b>this is html</b>" } }) </script> </body> </html>