双向绑定:双方其中一方改变,另外一方也会跟着改变。
data() {
return {inputValue: '',list: [],message: 'hello',checked: true,radio: '',select: [],options: [{text: 'A', value:{value: 'A'}},{text: 'B', value:{value: 'B'}},{text: 'C', value:{value: 'C'}}],
}
},
// 双向绑定 <input v-model="message" />
// <textarea v-model="message" />
// <input type="checkbox" v-model="checked">
// <input type="radio" v-model="radio" value="jack">
// 修饰符: lazy, number, trim(去除字符串前后空格)template: `<div>{{message}}{{radio}}{{select}}<input v-model="message" /><textarea v-model="message" /><input type="checkbox" v-model="checked" value="jack"><input type="radio" v-model="radio" value="jack"><select v-model="select"><option v-for="item in options" :value="item.value">{{item.text}}</option></select></div>`// template:// '<div> <input v-model="inputValue"/> <button v-on:click="handleAddItem">增加</button> <ul><li v-for="(item, index) of list"> {{item}} {{index}}</li> </ul> </div>'}).mount('#root');
仅供自己学习参考