ref-獲取dom
阿新 • • 發佈:2021-12-14
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<script src="../js/vue.js"></script>
<style>
</style>
</head> <body> <div id="root"></div> <script> // ref-獲取dom 節點 var app = Vue.createApp({ setup(){ const {ref,onMounted} = Vue const hello = ref(null) onMounted(()=>{ console.log(hello.value); }) return { hello } },
template:` <div> <div ref="hello"> hello world </div> </div> ` }) app.mount('#root')
</script>
</body> </html> 我是Eric,手機號是13522679763
</head> <body> <div id="root"></div> <script> // ref-獲取dom 節點 var app = Vue.createApp({ setup(){ const {ref,onMounted} = Vue const hello = ref(null) onMounted(()=>{ console.log(hello.value); }) return { hello } },
template:` <div> <div ref="hello"> hello world </div> </div> ` }) app.mount('#root')
</script>
</body> </html> 我是Eric,手機號是13522679763