87,993
社区成员
发帖
与我相关
我的任务
分享
<body>
<div id="app">
<custom-input v-model="something"></custom-input>
<br />
{{something}}
</div>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.7.0/lib/index.js"></script>
<script type="text/javascript">
Vue.component('custom-input', {
props: ['something'],
data() {
return { otherdata: 'hellow' };
},
template: '<input type="text" v-bind:value="something" v-on:input="updateValue($event.target.value)" v-bind:y="otherdata"/>',
methods: {
updateValue: function (value) {
this.$emit('input', parseInt(value) + 1);
this.otherdata = value; //问题所在语句
}
}
})
var vm = new Vue({
el: '#app',
data: {
something: '0'
}
})
</script>
</body>