【发布时间】:2020-05-29 05:16:04
【问题描述】:
我正在尝试生成具有可编辑字段和双向数据绑定的动态 b 表。
我不希望有任何硬编码值。现在,我有:
<b-table striped hover :items="filtered">
<template v-slot:cell(issueDescription)="row">
<b-form-input v-model="row.item.issueDescription" />
</template>
<template v-slot:cell(endTime)="row">
<b-form-input v-model="row.item.endTime" />
</template>
<template v-slot:cell(startTime)="row">
<b-form-input v-model="row.item.startTime" />
</template>
</b-table>
地点:
filtered = [ { "issueDescription": "this is a description", "endTime": "2020-02-11T14:00:00.000Z",
"startTime": "2020-02-11T01:24:00.000Z" }]
如果我使用 v-for 生成模板,那么我在每一列中都有可编辑的字段,但每个字段都没有绑定。
<b-table striped hover :items="filtered">
<template v-for="x in filtered" v-slot:cell()="row">
<b-form-input v-model="row.item.BIND_TO_SPECIFIC_TABLE_ROW_COL" />
</template>
</b-table>
如何绑定到特定的行,col??
我做了一个小提琴:https://jsfiddle.net/gfhu1owt/
【问题讨论】:
标签: vue.js dynamic generic-programming bootstrap-vue two-way-binding