console
Vue.component('base-input', {
inheritAttrs: false,
computed: {
inputListeners: function () {
var vm = this
return Object.assign({},
this.$listeners,
{
input: function (event) {
console.log(this)
vm.$emit('input', event.target.value)
}
}
)
}
},
template: `<label> {{ label }} <input v-bind:value="value" v-on="inputListeners">
<input >
</label>`
})
new Vue({
el:'#app',
data:{
message:'hello',
x:'',
value:'ds'
},
methods:{
write:function(x){
console.log(1,this.$listeners)
}
}
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="app">
<base-input v-on:input.native="write" v-model="x" value="" label="dddd"></base-input>
<p>{{ message }}</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
</body>
</html>