How to get the DOM element of the current Vue component?

When I am inside some method in vue-command and want to use some dom manipulation (by jquery), I need to get the coresponnding DOM element for my component (especially in the case when I have many instances of my component on the page - I I need to "work" separately for each of them - so I can not detect the DOM element using only the jquery selector without tricks ...)

+7
javascript jquery dom components
source share
1 answer

Just this (in any method in the "methods"):

let domElement = this.$el; 

:)

But remember that this is valid as long as your component is not a fragment instance , i.e. has one root HTML tag

+23
source share

All Articles