【发布时间】:2018-02-09 04:37:56
【问题描述】:
我正在前端构建一个动态表格,最后我需要知道表格的每个单元格中插入了什么,因为它是可编辑的,所以我在我的 html 上做了这个:
<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>
如你们所见。我在输入中设置了一个带有 items[idx1][idx2] 的 v-model,所以我可以将值传递给该行和列,它不是这样工作的,我不知道如何设置它。
这是我的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?
-
更新了问题
标签: javascript vue.js vuejs2