【发布时间】:2022-11-13 18:12:44
【问题描述】:
嗨,我正在尝试以这种方式输入:
itemPrices: [{regionId: "A", price: "200"},{regionId: "B", price: "100"}]
当用户按下添加按钮时,会添加新的输入字段。
为此,我在 vue 应用程序数据中采用了一个空数组 => itemPrices: [],。
现在在表格元素里面我有这个代码:
<vs-tr v-for="n in num" v-bind:key="n">
<vs-td
><vs-input
v-model="itemPrices[n].regionId"
placeholder="Region Name"
/></vs-td>
<vs-td>
<vs-input
placeholder="price"
v-model="itemPrices[n].price"
/>
</vs-td>
</vs-tr>
这里的“num”只是一个整数,它决定应该有多少行。但这不起作用......这个任务的可能解决方案是什么?
【问题讨论】:
标签: javascript html vue.js vuejs3 v-for