vue.js数据绑定语法

Vue.js数据绑定语法 (2)

原始高清大图下载

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>
posted @ 2016-07-11 17:56  fankeke  阅读(344)  评论(0)    收藏  举报