<template>
<div>
<input type="text" :value="text" @input="changeInput" />
<div @click="mychange">Button</div>
</div>
</template>
<script>
export default {
name: "Input",
data() {
return {
text: "default"
};
},
methods: {
changeInput: function() {
console.log("change");
},
mychange: function() {
console.log("button");
this.text = "not default";
}
}
};
</script>
v-model
+ watch
:<input v-model="text">
watch: {
text(newVal, oldVal) {
console.log(newVal, oldVal);
},
},