<body>
<div id="app"> <p>总数:{{total}}</p> <my-component v-model="total"> </my-component> <button @click="handleGetTotal"></button> </div></body> <script src="https://unpkg.com/vue/dist/vue.min.js"></script><script> Vue.component('my-component',{ prors:['value'], template:'<input :value="value" @input="handleIncrease"/>', methods:{ handleIncrease:function(event){ this.$emit('input',event.target.value); }, } }); var app=new Vue({ el:'#app', data:{ total:0 }, methods:{ handleGetTotal:function(){ this.total--; } } })</script>
中间template:'<input :value="value" @input="handleIncrease"/>',这句话什么意思,这个value怎么来的,浏览器报错也说value未定义
叮当猫咪
相关分类