nickmessing / babel-plugin-jsx-v-model

JSX Syntactic Sugar Plugin for v-model
MIT License
155 stars 12 forks source link

Support custom model prop and event #10

Open LucienLee opened 6 years ago

LucienLee commented 6 years ago

In vue 2.2.0+, it support to customize v-model binding prop and event by model . However, this plugin still transform to default value and input when specifying model. I hoped that it could adopt model property.

example

Vue.component('my-checkbox', { 
  model: { 
    prop: 'checked', 
    event: 'change'
  }, 
  props: { // this allows using the `value` prop for a different purpose 
     value: String,  // use `checked` as the prop which take the place of `value`  
     checked: { 
        type: Number,
        default: 0
     }
  }, 
  // ...
})
<my-checkbox v-model="foo" value="some value"></my-checkbox>
nickmessing commented 6 years ago

@LucienLee, hey, yes, I'll do that when I'm merging this into vuejs/jsx