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 ></div>

相关文章:

  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2021-06-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案