Javascript 将字符串数组传递给prop vue
我正在尝试将字符串数组传递给一个属性Javascript 将字符串数组传递给prop vue,javascript,vue.js,Javascript,Vue.js,我正在尝试将字符串数组传递给一个属性 <vue-component attributes="[Attribute0, Attribute1, Attribute2]"></vue-component> 向道具传递字符串数组的正确语法是什么?如果仔细阅读以下内容,您实际上是在传递字符串: <vue-component attributes="[Attribute0, Attribute1, Attribute2]"></vue-component>
<vue-component attributes="[Attribute0, Attribute1, Attribute2]"></vue-component>
向道具传递字符串数组的正确语法是什么?如果仔细阅读以下内容,您实际上是在传递字符串:
<vue-component attributes="[Attribute0, Attribute1, Attribute2]"></vue-component>
您应该能够像这样传递字符串数组:
<vue-component :attributes="['Attribute0', 'Attribute1', 'Attribute2']"></vue-component>
您应该在道具前使用
:
,并使用引号:
<vue-component :attributes="['Attribute0', 'Attribute1', 'Attribute2']"></vue-component>
不仅如此,还需要使用v-bind:attributes
使用快捷语法修复;)谢谢你的注意@Terry@matt:
最终只是一个v-bind
:
<vue-component :attributes="['Attribute0', 'Attribute1', 'Attribute2']"></vue-component>