DOM元素到相应的vue.js组件 [英] DOM element to corresponding vue.js component
本文介绍了DOM元素到相应的vue.js组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何找到与DOM元素对应的vue.js组件?
How can I find the vue.js component corresponding to a DOM element?
如果我有
element = document.getElementById(id);
有没有相当于jQuery $ b $的vue方法b $(元素)
?
Is there a vue method equivalent to the jQuery
$(element)
?
推荐答案
正确的方法将使用 v-el
指令给它一个参考。那么你可以做这个。$$ [参考]
。
The proper way to do with would be to use the v-el
directive to give it a reference. Then you can do this.$$[reference]
.
在Vue 2中,refs用于元素和组件: http://vuejs.org/guide/migration.html#v-el-and-v-ref-replaced
In Vue 2 refs are used for both elements and components: http://vuejs.org/guide/migration.html#v-el-and-v-ref-replaced
这篇关于DOM元素到相应的vue.js组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文