我在我的前端建立一個動態表,並在最後我需要知道什麼插入我的表的每個單元格,因爲它是可編輯的,所以我對我的HTML:綁定多維數組與vuejs
<table class="table table-responsive">
<tbody>
<tr v-for="(row,idx1) in tableRows" :class="{headerRowDefault: checkHeader(idx1)}">
<td class="table-success" v-for="(col,idx2) in tableCols"><input v-model="items[idx1][idx2]" type="text" class="borderTbl" value="HEY"/></td>
</tr>
</tbody>
</table>
正如你們可以看到的那樣。我在輸入內部設置了一個帶有項[idx1] [idx2]的v模型,所以我可以將該值傳遞給該行和列,它不是這樣工作的,我不知道如何設置它。
這是我的javascript:
export default {
name: 'app',
data() {
return {
table: {
rows: 1,
cols: 1,
key: 'Table',
tableStyle: 1,
caption: '',
colx: []
},
hasHeader: true,
hasCaption: true,
insert: 1,
idx2: 1,
items: []
}
},
計算:{
tableStyles() {
return this.$store.getters.getTableStyles
},
tableRows() {
return parseInt(this.table.rows)
},
tableCols() {
return parseInt(this.table.cols)
}
預計項目數組:
items:[
["john","Micheal"]
["john","Micheal"]
["john","Micheal"]
["john","Micheal"]
]
您需要提供HTML模板爲我們理解這個問題 –
呵呵我曾經有過,奇怪的是沒有放置它 –
你在哪裏得到tableCols或tableRows? –