<template> <div ref="root">This is a root element</div> </template> <script> import { ref, onMounted, getCurrentInstance } from 'vue'; export default { setup() { const { proxy } = getCurrentInstance(); const root = ref(null); OnMounted (() => {// DOM elements will be allocated to ref // first console.log(root.value) after initial rendering; // <div> this is the root element </div> // the second kind of console.log(proxy.root); // <div> this is the root </div>}); return { root, }; }}; </script>Copy the code