vue-mixed-props
v1.1.3
Published
Vue 2.x plugin, which allows to pass an array of props containing both strings and objects
Downloads
7
Maintainers
Readme
vue-mixed-props
Let's say, application has a component, which already has some props defined as an array of strings and it is totally fine for developer or dev team to leave it as it is:
export default {
name: 'SampleComponent',
props: [ 'foo', 'bar', 'baz' ]
}
But then, one day, a new prop should be added with type and default value defined. Currently developer has to rewrite existing array of props into object just for adding 1 new prop with default value.
Current plugin allows using mixed array of strings and object for detailed props:
export default {
name: 'SampleComponent',
props: [
'foo',
'bar',
'baz',
{
tar: {
type: String,
default: 'Hi'
}
}
]
}
Or you can use object for props
with array of some string props:
export default {
name: 'SampleComponent',
props: {
$strings: ['foo', 'bar', 'baz'],
tar: {
type: String,
default: 'Hi'
}
}
}
Usage:
import Vue from 'vue'
import MixedProps from 'vue-mixed-props'
Vue.use(MixedProps)
Plugin works also with SSR.