【发布时间】:2021-01-08 19:03:05
【问题描述】:
这里的工作代码沙箱:https://codesandbox.io/s/crazy-bardeen-53qxk?file=/src/App.vue
我正在尝试在 el-table 中的 vuejs 中实现单选按钮。单击单选按钮时,我无法更改变量 ownedFilterGroups 中的状态。 ownedFilterGroups 中的actionFg 键可以根据用户选择的单选按钮获得值 0,1 或 2。我的方法有什么问题?我参考了https://getbootstrap.com/docs/4.0/getting-started/introduction/ 来创建单选按钮组。 PS: 移除 data-toggle 并没有解决问题。
<el-table
:data="ownedFilterGroups"
:default-sort="{ prop: 'FilterGroupId' }"
v-loading="loading.filter_groups"
max-height="400px"
stripe
>
<el-table-column
label="Filter Group ID"
:sortable="true"
width="350px"
>
<template slot-scope="scope">
{{ scope.row.filterGroupId }}
</template>
</el-table-column>
<el-table-column label="Action">
<template slot-scope="scope">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-outline-primary active">
<input
type="radio"
:name="scope.row.filterGroupId"
:id="1"
:value="1"
v-model="scope.row.actionFg"
/>
Replace With New Version
</label>
<label class="btn btn-outline-primary">
<input
type="radio"
:name="scope.row.filterGroupId"
:id="2"
:value="2"
v-model="scope.row.actionFg"
/>
Append New Version
</label>
<label class="btn btn-outline-secondary">
<input
type="radio"
:name="scope.row.filterGroupId"
:id="0"
:value="0"
v-model="scope.row.actionFg"
/>
Do Nothing
</label>
</div>
</template>
</el-table-column>
</el-table>
数据模型包含一个变量:
ownedFilterGroups: [{
actionFg: 0,
filterGroupId: "aaa"
},{
actionFg: 0,
filterGroupId: "bbb"
}]
【问题讨论】:
标签: javascript vue.js bootstrap-4 radio-button