http://jsfiddle.net/yoqda8fn/4/
Popovers require that the popover have a ref and that the targeted element have a v-popover directive.
For the ref I expect to use:
:ref="activeIndex"
For the directive I expect to use:
v-popover="'pop'+index"
I get an error:
Uncaught TypeError: Cannot read property '$refs' of undefined
Vue natively does not support binding ref to a variable. It has to be a string literal.
Is there another way to dynamically re-use a popover?
@xmas
You can do this by abstracting your popover in another component
<template>
<div class="dynamic-popover">
<el-popover
ref="dynamic"
placement="bottom"
width="400"
trigger="click">
<ul>
<li v-for="(tip, index) in tips" key="index">
{{ tip }}
</li>
</ul>
</el-popover>
<el-button v-popover:dynamic>tips</el-button>
</div>
</template>
<script>
export default {
name: 'dynamic',
props: {
tips: {
type: Array,
required: true
}
}
}
</script>
in my case inserting popover inside button html helped e.g.:
<el-button v-popover:dynamic>
<el-popover ref='dynamic' ... ></el-popover>
</el-button>
Had the same issue. In my case the error occurred when placing the popover after the button.
This gives an error:
<el-button v-popover:foo></el-button>
<el-popover ref="foo" ... ></el-popover>
This works as expected:
<el-popover ref="foo" ... ></el-popover>
<el-button v-popover:foo></el-button>
Maybe this needs some clarification in the documentation.
@visualjerk Thanks. Anyway to have that foo value from a variable? I have a for loop.
Most helpful comment
in my case inserting popover inside button html helped e.g.: