useVModel
Shorthand for v-model binding, props + emit -> ref
Usage
js
import { useVModel } from '@vueuse/core'
export default {
setup(props, { emit }) {
const data = useVModel(props, 'data', emit)
console.log(data.value) // props.data
data.value = 'foo' // emit('update:data', 'foo')
},
}
<script setup>
Build faster with AI
New Masterclass to help you leverage AI in your Vue workflow.
Build faster with AI
New Masterclass to help you leverage AI in your Vue workflow.