this.$el
- points to the root element of the componentthis.$refs.<ref name>
+ <div ref="<ref name>" ...
- points to nested element use
$el
/$refs
only aftermounted()
step of vue lifecycle
<template>
<div>
root element
<div ref="childElement">child element</div>
</div>
</template>
<script>
export default {
mounted() {
let rootElement = this.$el;
let childElement = this.$refs.childElement;
console.log(rootElement);
console.log(childElement);
}
}
</script>
<style scoped>
</style>