Vue mixin to support an optional prop by falling back to a local data
npm install vue-prop-data-fallback> Vue mixin to support an optional prop that falls back to a local data
``sh`
npm install vue-prop-data-fallback
The example below will create a prop named value, a local variable _$value (the fallback) and a computed property $value.
`vue
`
Now the search input's value can be optionally controlled by the parent:
`html`
- prop: name of the prop that should be createdevent
- : name of the event that should be emitted to enable the usage of .sync or v-model. Defaults to 'update:' + prop (to enable the .sync modifier by default)propType
- : value provided to the prop option. Can be a type like String, Boolean, an array of types or an object (pretty much anything here). Defaults to { required: false }options
- : extra options to customize the names of the data and computed propertiesdata
- : name of the property added to data. Defaults to '_$' + propcomputed
- : name of the property added to computed. Defaults to '_$' + propinitialValue`: provides an initial value to be used when no prop is provided
-