vue element 同一个el-popover重复使用多次

574 阅读1分钟
<el-popover
    ref="pop1"
    placement="bottom-start"
    width="460"
    v-model="visible">
    <div>当前:{{curObj}}</div>
</el-popover>

<a v-for="(obj,index) in objs" :key="obj" style="cursor:pointer" @click="e=> showPop(e, obj)">
showPop(e, obj){
    this.curObj = obj
    //关键代码
    //先隐藏并销毁之前显示的
    this.visible = false
    var pop1 = this.$refs.pop1
    pop1.doDestroy(true)
    this.$nextTick(() => {
        //显示新的
        pop1.referenceElm = pop1.$refs.reference = e.target
        this.visible = true
    })
}