Skip to content

useVModel

Category
Export Size
533 B
Last Changed
11 months ago
Related

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>
AI-Driven Development
You. But 10x faster
The structured masterclass to help you leverage AI and build with an edge
Join Early