2021-03-25 22:33:41 +08:00
|
|
|
<template>
|
|
|
|
<div class="container">
|
|
|
|
<nav>
|
2021-04-04 00:17:54 +08:00
|
|
|
<div :id="tag" class="nav nav-pills" role="tablist">
|
2021-03-25 22:33:41 +08:00
|
|
|
<button
|
|
|
|
v-for="tab of children"
|
2021-05-28 22:11:48 +08:00
|
|
|
:id="tab.id + '-label'"
|
|
|
|
:aria-controls="tab.id"
|
|
|
|
:data-bs-target="'#' + tab.id"
|
2021-03-25 22:33:41 +08:00
|
|
|
aria-selected="false"
|
2021-04-04 00:17:54 +08:00
|
|
|
class="nav-link"
|
|
|
|
data-bs-toggle="tab"
|
|
|
|
role="tab"
|
|
|
|
type="button"
|
2021-03-25 22:33:41 +08:00
|
|
|
>
|
|
|
|
{{ tab.title }}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</nav>
|
2021-03-26 10:15:33 +08:00
|
|
|
<div :id="contentTag" class="tab-content">
|
2021-03-25 22:33:41 +08:00
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-04-06 23:47:32 +08:00
|
|
|
import { defineComponent } from "vue";
|
2021-03-25 22:33:41 +08:00
|
|
|
|
2021-04-06 23:47:32 +08:00
|
|
|
export default defineComponent({
|
2021-03-25 22:33:41 +08:00
|
|
|
props: {
|
|
|
|
title: {
|
2021-04-04 14:38:46 +08:00
|
|
|
type: String,
|
|
|
|
},
|
2021-03-25 22:33:41 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-04 14:38:46 +08:00
|
|
|
children: [],
|
2021-03-25 22:33:41 +08:00
|
|
|
};
|
|
|
|
},
|
2021-04-06 23:47:32 +08:00
|
|
|
beforeMount() {
|
2021-04-04 14:38:46 +08:00
|
|
|
this.children = [];
|
2021-03-25 22:33:41 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
2021-05-28 22:11:48 +08:00
|
|
|
this.$nextTick(async function () {
|
|
|
|
const bootstrap = await import("bootstrap");
|
|
|
|
let triggerEl = document.getElementById(this.children["0"].id + "-label");
|
|
|
|
new bootstrap.Tab(triggerEl).show();
|
2021-03-25 22:33:41 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
computed: {
|
2021-04-04 14:38:46 +08:00
|
|
|
tag: function () {
|
2021-03-25 22:33:41 +08:00
|
|
|
return "tabs-" + this.title;
|
2021-03-26 10:15:33 +08:00
|
|
|
},
|
2021-04-04 14:38:46 +08:00
|
|
|
contentTag: function () {
|
2021-03-26 10:15:33 +08:00
|
|
|
return "tabs-" + this.title + "-content";
|
2021-04-04 14:38:46 +08:00
|
|
|
},
|
|
|
|
},
|
2021-03-25 22:33:41 +08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-05-03 12:57:54 +08:00
|
|
|
@import "node_modules/bootstrap/scss/bootstrap";
|
2021-04-04 00:17:54 +08:00
|
|
|
|
|
|
|
button.nav-link {
|
2021-05-28 22:39:40 +08:00
|
|
|
color: var(--c-text-accent);
|
|
|
|
&:hover,
|
|
|
|
&:focus {
|
|
|
|
color: var(--x-nav-text-hover);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nav {
|
|
|
|
padding-bottom: 0.5rem;
|
|
|
|
border-bottom: 1px solid var(--c-border);
|
|
|
|
}
|
|
|
|
div.tab-content {
|
|
|
|
border-bottom: 1px solid var(--c-border);
|
2021-04-04 00:17:54 +08:00
|
|
|
}
|
2021-03-25 22:33:41 +08:00
|
|
|
</style>
|