2021-05-03 12:57:54 +08:00

42 lines
787 B
Vue

<template>
<div
class="tab-pane fade"
:id="tabID"
role="tabpanel"
:aria-labelledby="labelID"
>
<slot />
</div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
props: {
title: {
type: String,
},
},
data() {
return {
tabID: "",
labelID: "",
};
},
beforeMount() {
let tag = "tab-" + Math.random().toString(36).substring(2);
this.tabID = tag;
this.labelID = tag + "-" + "label";
// 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);
},
});
</script>
<style lang="scss" scoped>
@import "node_modules/bootstrap/scss/bootstrap";
</style>