All files / src/components/u-info-list.vue index.vue

40.62% Statements 13/32
33.33% Branches 2/6
11.11% Functions 1/9
41.93% Lines 13/31

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      7x     7x             7x                                                                
<template>
<div :class="$style.root">
    <slot></slot>
</div>
</template>
 
<script>
export default {
    name: 'u-info-list',
    groupName: 'u-info-list-group',
    childName: 'u-info-list-item',
    props: {
        column: [String, Number],
        labelSize: String,
        repeat: { type: [String, Number], default: 3 },
        showHead: { type: Boolean, default: true },
    },
    data() {
        return { groupVMs: [], itemVMs: [] };
    },
    created() {
        this.$on('add-group-vm', (groupVM) => {
            groupVM.parentVM = this;
            this.groupVMs.push(groupVM);
        });
        this.$on('remove-group-vm', (groupVM) => {
            groupVM.parentVM = undefined;
            this.groupVMs.splice(this.groupVMs.indexOf(groupVM), 1);
        });
        this.$on('add-item-vm', (itemVM) => {
            itemVM.parentVM = this;
            this.itemVMs.push(itemVM);
        });
        this.$on('remove-item-vm', (itemVM) => {
            itemVM.parentVM = undefined;
            this.itemVMs.splice(this.itemVMs.indexOf(itemVM), 1);
        });
    },
};
</script>

<style module>
/* 避免受嵌套的父级组件影响 */
.root { white-space: normal; }
</style>