Vue 2 - How to set default type of array in props
ES6 variety For an Array
props: {
arr: {
type: Array,
default: () => []
}
}
...And for an Object
props: {
obj: {
type: Object,
default: () => ({
param: value,
param2: value,
})
}
}
A couple related resources:
- https://github.com/vue-styleguidist/vue-styleguidist
- https://github.com/vuejs/vue/issues/1032
I created example: jsFiddle, that might can help you, and yes... you can return the default value as a array:
ES6
props: {
items: {
type: Array,
default: () => []
}
}