<template>
    <component :is="is"
               ref="comp"
               v-if="is"
               v-show="show_"/>
</template>

<script>
export default {
    name: "OnceComp",
    data() {
        return {
            is: null,
            show_: true,
        }
    },
    methods: {
        show() {
            this.show_ = true;
        },
        hide() {
            this.show_ = false;
        },
        changeIs(is) {
            let vm = this;
            vm.is = null;
            return new Promise(resolve => {
                vm.$nextTick(() => {
                    vm.is = is;
                    vm.$nextTick(() => {
                        resolve(vm.$refs.comp);
                    });
                });
            })
        },
    }
}
</script>

<style scoped>

</style>
