【发布时间】:2017-06-18 11:25:36
【问题描述】:
我在 vue js 中有一个全局指令
Vue.directive('customDirective',{
bind(el,binding,vnode){
// need to get the parent
// append a div after the input element
}
})
我有以下 html 代码。
<div class="parentDiv">
<input type="text" name="firstName" v-customDirective="Some text"/>
</div>
<div class="parentDiv"> is loading dynamically via jquery。我需要获取输入标记的父级,并且需要在输入标记之后附加一些 html。我尝试过使用 parent(),但它显示为 parent 不是函数。有什么建议吗?
【问题讨论】:
-
parentDiv何时添加到 DOM? Vue创建后?