这里,**@input的作用是DomLinsteners,:value的作用是DataBindings**
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <div id="app"> <input type="text" v-model="msg"><br> <input type="text" v-bind:value="msg" v-on:input="handle"><br> <input type="text" :value="msg" @input="msg=$event.target.value"><br> <div>{{msg}}</div> </div> <script src="../../js/vue.js"></script> <script> let app = new Vue({ el: '#app', data: { msg: '', }, methods: { handle: function (event){ this.msg = event.target.value; } } }) </script>
|