-1👍
The v-model in Vue is actually combine with a prop call value
and a event call input
.
So you can do this by listening to input
event.
or simply bind the value to style
new Vue({
el: '#app',
template: `
<div>
<input value="haha" type="text" @input="update" v-model="v" />
<span :style="{width: `${v}px`}"></span>
</div>`,
data: function() {
return {
v: ''
}
},
methods: {
update: function() {
// update your style through input event
// or simply bind your value to the style
}
}
})
Source:stackexchange.com