【发布时间】:2021-03-30 21:20:09
【问题描述】:
我希望能够在 vue 中为我的表格添加自定义颜色作为背景
这是我的 .vue 文件:
<template>
....
<b-table small :fields="fields" :items="items">
<template #cell(name)="data">
<b>{{ data.value.name }}</b>
</template>
....
</b-table>
....
<template>
<script>
export default {
data () {
return {
items: [
{ name: { name: '....', url: '....' }, utility: '....', icon: '../assets/.....png', _rowVariant: 'light' },
{ name: { name: '....', url: '....' }, utility: '....', icon: '../assets/.....png', _rowVariant: 'success' },
{ name: { name: '....', url: '....' }, utility: '....', icon: '../assets/.....png', _rowVariant: 'danger' },
{ name: { name: '....', url: '....' }, utility: '....', icon: '../assets/.....png', _rowVariant: 'custom-one' }
],
tableVariants: ['primary', 'secondary', 'info', 'danger', 'warning', 'success', 'light', 'dark','custom-one', 'custom-two', 'custom-three' ],
..........
</script>
<style lang="scss" scoped>
@import '../scss/custom.scss';
.........
</style>
如您所见,我正在尝试从 Array tableVariant 中声明的 $theme-colors 导入。
我的 custom.scss 文件:
$purple: #6f42c1 !default;
$porpora: #75151e !default;
$orange: #fd7e14 !default;
$theme-colors:(
"custom-one": $orange,
"custom-two": $purple,
"custom-three": $porpora
);
@import "../../node_modules/bootstrap/scss/bootstrap";
如何添加 _rowVariant 自定义颜色? 谢谢!
【问题讨论】:
-
您为什么要将
custom.scss文件导入组件而不是全局文件?
标签: vue.js bootstrap-4 sass bootstrap-vue