Popover: fix error when reference comes before popover (#10273)

pull/10275/head
杨奕 2018-03-21 10:54:33 +08:00 committed by GitHub
parent 0fa60fe264
commit 1362bae57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,16 @@
export default {
bind(el, binding, vnode) {
// vue中 v-popover:argument 和 v-popover="variate|| expression"得到的binding数据是不同的。后者可以指向动态popver组件可以极大的增强popover指令的灵活程度。
const _ref = binding.expression ? binding.value : binding.arg;
vnode.context.$refs[_ref].$refs.reference = el;
const getReference = (el, binding, vnode) => {
const _ref = binding.expression ? binding.value : binding.arg;
const popper = vnode.context.$refs[_ref];
if (popper) {
popper.$refs.reference = el;
}
};
export default {
bind(el, binding, vnode) {
getReference(el, binding, vnode);
},
inserted(el, binding, vnode) {
getReference(el, binding, vnode);
}
};