2021-03-25 22:33:41 +08:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="tab-pane fade"
|
|
|
|
:id="tabID"
|
|
|
|
role="tabpanel"
|
|
|
|
:aria-labelledby="labelID"
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</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 {
|
|
|
|
tabID: "",
|
2021-04-04 14:38:46 +08:00
|
|
|
labelID: "",
|
2021-03-25 22:33:41 +08:00
|
|
|
};
|
|
|
|
},
|
2021-04-04 00:17:54 +08:00
|
|
|
beforeMount() {
|
2021-04-04 14:38:46 +08:00
|
|
|
let tag = "tab-" + Math.random().toString(36).substring(2);
|
2021-03-25 22:33:41 +08:00
|
|
|
this.tabID = tag;
|
|
|
|
this.labelID = tag + "-" + "label";
|
2021-04-04 14:38:46 +08:00
|
|
|
|
|
|
|
// Since Vue 3.0, we have no access to $children.
|
|
|
|
// So we need another approach to register our child components.
|
|
|
|
this.$parent.$data.children.push(this);
|
|
|
|
},
|
2021-03-25 22:33:41 +08:00
|
|
|
});
|
|
|
|
</script>
|
2021-04-06 23:47:32 +08:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-05-03 12:57:54 +08:00
|
|
|
@import "node_modules/bootstrap/scss/bootstrap";
|
2021-04-06 23:47:32 +08:00
|
|
|
</style>
|