Skip to content

Provide a way to pass modelModifiers to a native input #1825

@pearofducks

Description

@pearofducks

What problem does this feature solve?

Currently there's no way to pass the built-in modifiers to a native input. So wrapping a native input now would need to duplicate code that the vModelText directive already seems to include - or eject to a render function.

<my-input v-model.lazy="foo" />

...

MyInput.vue

<template>
  <input v-bind="$attrs" v-model="model">
</template>

<script>
import { computed } from 'vue'

export default {
  setup: (props, { emit }) => ({
    model: computed({
      get: () => props.modelValue,
      set: v => emit('update:modelValue', v)
    })
  })
}
</script>

What does the proposed API look like?

I don't have any strong opinions here - the native input could simply look for modelModifiers so that v-bind="$attrs" "just works"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions