我在VUE JS无法html元素添加到父在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(),但它显示为父级不是函数。有什么建议么 ?
何时将'parentDiv'添加到DOM? Vue创建之后? – Bert