我尝试通过引导示例更改它,但失败。
<b-pagination
v-model="currentPage"
:total-rows="users.length"
:per-page="perPage"
align="fill"
size='lg'
first-number
last-number
class="my-0"
></b-pagination>
Bootstrap-vue在更改默认主题颜色时确实不那么灵活,但是有可能。
您首先必须创建一个custom.scss
文件,您可以在其中将新的颜色主题添加到bootstrap-vue。
在src/assets/styles/custom.scss
上:
// Override / set color variables
$myCustom: rgba(64, 206, 148, 1);
$primary: $myCustom;
请注意,在上面的示例中,所有不带变量集的自举元素-包括分页-都将显示$myCustom
颜色。
然后,您必须在根vue组件上导入此文件和原始的scss引导程序文件:
<style lang="scss">
@import "./assets/styles/custom.scss";
@import "../node_modules/bootstrap/scss/bootstrap.scss";
</style>
在您的代码示例中,您相应地传递了变体:
<b-pagination
v-model="currentPage"
:total-rows="users.length"
:per-page="perPage"
align="fill"
size='lg'
first-number
last-number
class="my-0"
variant="primary"
></b-pagination>
如果您不想修改默认的原色,则可以在custom.scss
上创建一个新的变体:
$theme-colors: ( "newVariant": rgba(0, 152, 152, 1));
希望它很适合您
您可以将一个类添加到b-pagination
,并使用该类来定位分页内的a
标签。请查看摘要以获取示例。
您还可以使用以下道具(需要v2.3.0+
)在各种类型的按钮上放置特定的类。注意,这些会将类放置在li
上,因此您仍然需要CSS来定位a
标签。有关类道具的更多信息,请检查reference section
page-class
first-class
last-class
prev-class
next-class
ellipsis-class
[如果您在组件中使用scoped
样式标签,请注意,您可能必须使用deep selector才能正确定位a
标签。
new Vue({
el: '#app'
})
.customPagination > li > a {
color: red;
}
.customPagination > li.active > a,
.customPagination > li > a:hover
{
color: white;
background-color: green!important;
}
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/bootstrap-vue.js"></script>
<link href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/[email protected]/dist/bootstrap-vue.css" rel="stylesheet"/>
<div id="app">
<b-pagination
:total-rows="50"
:per-page="5"
class="customPagination"
>
</b-pagination>
</div>