Skip to content

useVModel

Category
Export Size
533 B
Last Changed
last year
Related

简化 v-model 绑定的简写方式,将 props + emit 转换为 ref

用法

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.
Get Early Access