gpt4 book ai didi

vue.js - bootstrap-vue 问题与 b-table 中的复选框

转载 作者:搜寻专家 更新时间:2023-10-30 22:41:49 24 4
gpt4 key购买 nike

我在让复选框正常工作时遇到了问题。为“选定”插槽中的每一行呈现的复选框未绑定(bind)到正确的行。当您单击复选框时,它会将顶行的复选框设置为 true/false 位置。

问题:1)如何将行复选框的真/假状态绑定(bind)到它的行项目?我试图将它绑定(bind)到 data.item.selected,然后遍历数据以找到“选定”对象并执行必要的操作。我什至尝试将行对象添加到新的数据数组,但它只添加了第一行?

2) 根据 HEAD_selected 插槽复选框将所有行复选框的 true/false 设为 true/false 的最佳方法是什么?

代码:

<b-table 
striped
hover
outlined
:items="schools"
:fields="fields"
:per-page="perPage"
:current-page="currentPage"
:total-rows="totalRows"
:sort-by.sync="sortBy"
:sort-desc.sync="sortDesc">

<template slot="HEAD_selected" slot-scope="data">
<b-form-checkbox @click.native.stop v-model="allSelected">
</b-form-checkbox>
</template>

//Not working. data.item.selected is always the top row in all of the results, not it's current position
<template slot="selected" slot-scope="data">
<b-form-checkbox id="checkbox" @click.stop v-model="data.item.selected">
</b-form-checkbox>
</template>

</b-table>

最佳答案

回答:

问题出在 b-form-checkbox 中的 id。 id="checkbox"绑定(bind)到同一个复选框。一旦我将其更改为 :id="'checkbox'+data.index"它就起作用了!

关于vue.js - bootstrap-vue 问题与 b-table 中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52883287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com