五. Vue-属性绑定

    技术2023-07-09  102

    属性绑定

    1.vue如何动态处理属性

    v-bind:

    控制标签元素属性的动态变化

    <div id="app"> <a v-bind:href="url">b站</a> <button @click="handle">切换</button> </div> methods: { handle:function(){ this.url="https://home.firefoxchina.cn/"; } 缩写形式 <a :href="url">b站</a>

    2.v-model的底层使用原理分析

    <input v:bind:value="msg" v-on:input="msg=$event.target.value"> <input v:bind:value="msg" v-on:input="handle"> <input v-model="msg"> <!--这三者的使用效果完全相同 -->
    Processed: 0.009, SQL: 9