vue.js数据绑定语法

1.数据绑定
html代码:
<div id="first" class="first">msg:{{msg}}</div>
tips:双{{msg}}输出值为为解析后的纯文本,若要输出html则应用{{{msg}}}
js代码:
var vm=new Vue({ el:'#first', data:{msg:'hello vue.js'}, created: function () { // `this` 指向 vm 实例 console.log('a is: ' + this.msg) } });
执行效果:
msg:hello vue.js
tips:vue.js还支持在 HTML 特性 (Attributes) 内绑定数据
<div id="item-{{ id }}"></div>

浙公网安备 33010602011771号