vue.js - bootstrap-vue 切换扩展表行

标签 vue.js bootstrap-4 bootstrap-vue

这似乎仍然没有答案,所以这里是另一种解决方案的尝试。

目前在 bootstrap-vue 中,我正在渲染 b-table .我想通过能够选择一行并折叠/展开额外的 div/row/etc 以显示更多信息来改进这一点。

在下面的片段中,您将看到我正在尝试的内容。问题是我似乎无法获得扩展数据以跨越表中的列数。我试过添加 <tr><td colspan="6"></td></tr>但它似乎并没有像我期望的那样跨越。有什么解决方法吗?谢谢。

<b-table
    :items="case.cases"
    :fields="tableFields"
    head-variant="dark">
    <template
        slot="meta.status"
        slot-scope="data">
    <b-badge
        v-b-toggle.collapse1
        :variant="foobar"
        tag="h6">
        {{ data.value }}
    </b-badge>
    </template>
    <template
        slot="@id"
        slot-scope="data">
        <span
            v-b-toggle.collapse1>
            {{ data.value }}
        </span>
        <b-collapse id="collapse1">
            Collapse contents Here
        </b-collapse>
    </template>
</b-table>`

最佳答案

听起来您可以使用 行详情投币口:

If you would optionally like to display additional record information (such as columns not specified in the fields definition array), you can use the scoped slot row-details



<b-table :items="case.cases" :fields="tableFields" head-variant="dark">
  <template slot="meta.status" slot-scope="data">
    <b-button @click="data.toggleDetails">
        {{ data.value }}
    </b-button>
  </template>
  <template slot="row-details" slot-scope="data">
    <b-button @click="data.toggleDetails">
        {{ data.detailsShowing ? 'Hide' : 'Show'}} Details }}
    </b-button>
    <div>
       Details for row go here.
       data.item contains the row's (item) record data
       {{ data.item }}
    </div>
  </template>
</b-table>

https://bootstrap-vue.js.org/docs/components/table#row-details-support 的文档中有一个很好的例子

关于vue.js - bootstrap-vue 切换扩展表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54575878/

相关文章:

javascript - Bootstrap-Vue 表未使用 table.refresh() 更新

docker - VueCLI3 应用程序 (nginx/docker) 使用环境特定变量

javascript - Vue.js:v-repeat 未从 JSON 数组获取数据

carousel - 在小型设备上看不到bootstrap 4轮播字幕

html - nav navbar-nav 不可用?

css - Bootstrap 4 和 css 变换旋转

vue.js - 在 Vue 2.0 中切换 CSS 类

javascript - 大型网站中的 Vuex 商店架构

javascript - 如何将模板(槽)从祖父组件传递给 VueJS 中的孙组件?

vue.js - 如何用 jest 在单元测试中测试 bootstrap vue 组件的存在?