Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useVModel can not use v-model with vue2 #302

Closed
likeswinds opened this issue Jan 25, 2021 · 3 comments
Closed

useVModel can not use v-model with vue2 #302

likeswinds opened this issue Jan 25, 2021 · 3 comments

Comments

@likeswinds
Copy link
Contributor

how about this

  let event = `update:${key}`
  const model = vm?.$options.model
  if (model?.prop === key) {
    event = model?.event!
  }
  return computed<P[K]>({
    get() {
      return props[key!]
    },
    set(value) {
      _emit(event, value)
    }
  })
@likeswinds likeswinds changed the title useVModel can not use v-model useVModel can not use v-model with vue2 Jan 25, 2021
@antfu
Copy link
Member

antfu commented Jan 26, 2021

Are you talking about custom v-model options? I think this could do but should only apply when there is no key provided. Would you like to create a PR for it? Thanks.

@likeswinds
Copy link
Contributor Author

yes,custom v-model. I haven't created PR yet, but I'll try.

1 similar comment
@likeswinds
Copy link
Contributor Author

yes,custom v-model. I haven't created PR yet, but I'll try.

@antfu antfu closed this as completed in 3176133 Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants