From 5ae30dd98f56f6ad787fc810a30810c173179e72 Mon Sep 17 00:00:00 2001 From: daipeng <31502304+daipeng7@users.noreply.github.com> Date: Wed, 31 Jan 2018 15:54:32 +0800 Subject: [PATCH] Popover: v-popover directive supports expression (#9564) --- packages/popover/src/directive.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/popover/src/directive.js b/packages/popover/src/directive.js index a796395d..3ad8d942 100644 --- a/packages/popover/src/directive.js +++ b/packages/popover/src/directive.js @@ -1,5 +1,7 @@ export default { bind(el, binding, vnode) { - vnode.context.$refs[binding.arg].$refs.reference = el; + // 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; } };