<template>
    <div class="frame-box">
        <component :is="c"></component>
    </div>
</template>
<script>
import Vue from 'vue'
export default {
    props:{
        path:{
            type:String,
            default:''
        },
        name:{
            type:String,
            default:''
        },
        componentTemp:{
            type:Function
        },
        refer:{
            type:Number,
            default:0
        },
        value:{
            type:Array,
            default:null
        },
        type:{
            type:String,
            default:'d'
        },
        curIndex:{
            type:Number,
            default:0
        }
    },
    data () {
        return {
            hostory:[],
            c:'',
            z:0
        }
    },
    watch: {
        path:function(val,oldval){
            this.z++
            if(oldval!='' && this.type=='d'){
                this.value.push(val)
                this.$emit('input', this.value)
            }
            this.loadComp()
        },
        refer:function(val,oldval){
            this.z++
            this.loadComp()
        }
    },
    methods: {
        loadComp(){
            if(this.componentTemp){
                Vue.component(this.name+"_"+this.curIndex+"_"+this.z,this.componentTemp)
                this.c=this.name+"_"+this.curIndex+"_"+this.z
            }
        },
        pushPath(){
          this.value.push(this.path)
          this.$emit('input', this.value)
          this.MsgBus.$emit('forEachLoc')
        }
    },
    mounted () {
        this.loadComp()
        if(this.value.length==0)
            this.pushPath()
    }
}
</script>
