All files / src/components/u-tabs.vue tab.vue

94.73% Statements 18/19
45.45% Branches 5/11
100% Functions 3/3
94.44% Lines 17/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54      7x   7x     7x                                                                                          
<template>
<div :class="$style.root" v-show="selected" vusion-slot-name="default" :vusion-disabled-selected="true">
    <slot></slot>
    <s-empty v-if="!$slots.default && $env.VUE_APP_DESIGNER && !!$attrs['vusion-node-path']"></s-empty>
</div>
</template>
 
<script>
import { MSinglexItem } from '../m-singlex.vue';
import SEmpty from '../s-empty.vue';
 
export default {
    name: 'u-tab',
    parentName: 'u-tabs',
    components: { SEmpty },
    extends: MSinglexItem,
    props: {
        title: String,
        /* @TODO: Remove this option */
        hidden: {
            type: Boolean,
            default: false,
        },
        closable: { type: Boolean, default: false },
        showTabItem: { type: Boolean, default: true },
    },
    computed: {
        selected() {
            // console.log('tab', this.parentVM, this.active);
            return this.parentVM && (this.parentVM.router ? this.active : this.parentVM.selectedVM === this);
        },
    },
    updated() {
        // IDE里组件放入title插槽后没有重新渲染,这里强制渲染
        if (this.$env.VUE_APP_DESIGNER) {
            if (this.parentVM) {
                this.parentVM.$forceUpdate();
            }
        }
    },
    methods: {
        designerControl() {
            this.parentVM.select(this);
        },
    },
};
</script>
 
<style module>
.root {
    height: 100%;
}
</style>