<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> <div>{{msg}}</div>
//分行显示 <input type="text" v-bind:value="msg" v-on:input="handle">
//一行显示 <input type="text" v-bind:value="msg" v-on:input=msg=$event.target.value>
//v-model方式
<input type="text" v-model="msg">
</div> <script src="./js/vue.js"></script> <script> var vm = new Vue({ el: '#app', data: { msg: 'hello' }, methods: { handle: function(event) { this.msg = event.target.value; } } }) </script> </body> </html>
标签:绑定,msg,原理,model,event,底层 From: https://www.cnblogs.com/wangxianwen/p/16759087.html