vue自定义指令 调用函数传参

<div v-mydirect:fn="item"></div>
Vue.directive('mydirect', {
    bind (el, binding,vnode) {
        let that = vnode.context
        that[binding.arg](binding.value)
    }
})
methods:{
fn(item){
  console.log(item)
}

}

 

posted @ 2021-06-09 15:06  仙乄  阅读(1181)  评论(0编辑  收藏  举报