# 什么是虚拟dom

对象结构

h('#app',{
  
})
1
2
3

vue中ref访问的是虚拟dom

<template>
  <h1 :ref="(el) => child = el">123</h1>
</template>

<script>
export default {
  data() {
    return {
      child: null,
    }
  },
  mounted() {
    console.log(this.$refs); // {}
    console.log(this.child); // <h1>123</h1>
  }
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17