简体   繁体   English

如何在bootstrap-vue中的“ b-table”组件中使用插槽“ bottom-row”?

[英]How to use the slot “bottom-row” in “b-table” component in bootstrap-vue?

I have a component that uses bootstrap-vue b-table component. 我有一个使用bootstrap-vue b表组件的组件。 I need to make a result row, which will be the sum of each column. 我需要创建一个结果行,该行将是每一列的总和。 But when I try to use a bottom-row as a thead-top, then the bottom-row fills only the first column, ignoring the rest. 但是,当我尝试使用底部行作为thead-top时,底部行仅填充第一列,而忽略其余部分。 How to make it work like a thead-top? 如何使其像thead-top一样工作?

<b-table
    :items="items"
    :fields="fields"
    responsive="sm"
>
        <template slot="thead-top" slot-scope="data">
            <tr>
                <th colspan="2">&nbsp;</th>
            <th>Type 1</th>
            <th colspan="3">Type 2</th>
            <th>Type 3</th>
        </tr>
    </template>
    <template slot="bottom-row"
          slot-scope="data"
    >
        <tr>
            <th colspan="2">&nbsp;</th>
            <th>Type 1</th>
            <th colspan="3">Type 2</th>
            <th>Type 3</th>
        </tr>
    </template>
</b-table>

I realized what I was doing wrong. 我意识到自己做错了。 Tag is not needed in template slot="bottom-row". 模板slot =“ bottom-row”中不需要标记。

<template slot="bottom-row"
          slot-scope="data"
>
    <td v-for="(field, i) in data.fields">
         {{ i }}
    </td>
</template>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM