【发布时间】:2019-09-16 16:18:32
【问题描述】:
我有一个像this bootstrap table 这样的表的项目。
模板:
<b-table small :fields="fields" :items="items">
<template v-slot:cell(index)="data">
{{ data.index + 1 }}
</template>
<!-- A custom formatted column -->
<template v-slot:cell(name)="data">
<b class="text-info">{{ data.value.last.toUpperCase() }}</b>, <b>{{ data.value.first }}</b>
</template>
<!-- A virtual composite column -->
<template v-slot:cell(nameage)="data">
{{ data.item.name.first }} is {{ data.item.age }} years old
</template>
<!-- Optional default data cell scoped slot -->
<template v-slot:cell()="data">
<i>{{ data.value }}</i>
</template>
</b-table>
还有脚本:
fields: [
// A virtual column that doesn't exist in items
'index',
// A column that needs custom formatting
{ key: 'name', label: 'Full Name' },
// A regular column
'age',
// A regular column
'sex',
// A virtual column made up from two fields
{ key: 'nameage', label: 'First name and age' }
],
items: [
{ name: { first: 'John', last: 'Doe' }, sex: 'Male', age: 42 },
{ name: { first: 'Jane', last: 'Doe' }, sex: 'Female', age: 36 },
{ name: { first: 'Rubin', last: 'Kincade' }, sex: 'Male', age: 73 },
{ name: { first: 'Shirley', last: 'Partridge' }, sex: 'Female', age: 62 }
]
引导表有效。我正在复制此代码并且示例不起作用。我不明白为什么。
问题:那么,为什么引导表示例不起作用?
【问题讨论】:
-
请提供更多详细信息,如 vue 版本和控制台错误
-
您的沙箱为我生成了一个具有依赖关系的工作示例:
bootstrap:4.3.1、bootstrap-vue:2.0.1和vue:2.6.10。对于低于2.0.0的bootstrap-vue的版本,我会遇到一些奇怪的行为。 -
谢谢!我更新了依赖项并且一切正常!
标签: vue.js bootstrap-vue