我试图一起使用tether
和vue 2.2.1
。这是一个jsfiddle示例:https://jsfiddle.net/awei01/fwttsa6o/2/
我认为tether
做了什么:
如果系留DOM节点位于普通文档流程内(不是position: absolute
),tether
代码将只添加一些样式属性来正确定位系留元素
如果系留DOM节点有position: absolute
,tether
将移动系留DOM节点并将其置为body
的子节点。这会导致vue
出现问题。具体而言,抛出异常:DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
我试图通过摆弄beforeDestroy
组件的destroyed
,Popup
生命周期钩子来解决此问题,但它似乎没有帮助。
我能够通过简单地将系留DOM元素移回react
生命周期钩子上的原始位置来解决componentWillUnmount
中的这个问题。
我想知道在vue
中解决此问题的最佳方法是什么。我的另一个想法是抢先将新的DOM节点插入body
并强制Popup
组件使用该节点进行渲染,但我无法弄清楚如何做到这一点。
任何建议都表示赞赏。感谢
答案 0 :(得分:0)
从v-if
更改为v-show
似乎解决了这个问题。
<popup v-show="popup1" target="anchor1">
Some popup content
</popup>