vue常用的指令

vue常用的指令
<body>
     <div id="app">
            <h1>{{ msg }}</h1>      //数据写入方式
            <h2 v-text="msg"></h2>   //v-text写入数据,但是标签名内不能再写入其他的值,因为会被v-text覆盖
            <h2 v-once="msg">{{ msg }}</h3>   //v-once本身不能写入值,他只是制定标签内的某个相关的值不会随实例中数据动态发生改变

             <h2>{{ msg }}</h2>
            <input type="text" v-model="msg">  //使用v-model进行双向绑定 让h2标签内的数据与表单里面的数据联动

             <h2 v-bind:title="msg">给h2绑定title属性</h2>  //v-bind为h2标签绑定title属性
            <h2 :title="msg">v-bind的简写方式</h2>          //v-bind为h2标签绑定title属性的简写方式
            <h2 v-bind={id:"id", class:"class"}>绑定id,className</h2>   //v-bind也可以绑定一个对象
     </div>

    <script>
            var vm = new Vue({
                                el: "#app",
                               data: {
                                       msg: "vue中常用指令!"
                               }
            })
    </script>
</body>
posted @ 2017-09-21 10:32  不乱来的嫖客  阅读(237)  评论(0编辑  收藏  举报