I have a props in vue like this,
props: {
variant : String
}
but I want it to be an array if the value of variant is greater than 1. How can I do it?
you can use computed to replace it
props: {
variant : String
},
computed: {
computedVariant() {
return this.variant.length > 1 ?
[this.variant] :
this.variant
}
}
then use the computedVariant instead of variant in your template
<div>{{ computedVariant }}</div>