<body>
<p id="app">
<p class="con1" @click="click">
vue
<p class="con2"></p>
</p>
</p>
<script>
var vm = new Vue({
el: '#app',
mounted() {
for (let i of this.$el.children) {
console.log(i)
}
},
methods: {
click() {
for (let i = 0; i < this.$el.children.length; i++) {
console.log(this.$el.children[i])
}
}
}
})
</script>
</body>
It is obviously nested, but after generation it is the same level
學(xué)習(xí)是最好的投資!
This is followed by the vue
沒關(guān)系,是因?yàn)闉g覽器渲染的時(shí)候不允許 <p>
標(biāo)簽包含 <p>
標(biāo)簽,所以你自己看下,實(shí)際渲染生成了三個(gè) <p>
tag.
Throw it aside vue
and write a separate one
<p>1
<p>2</p>
3</p>
You will also find that it is rendered by the browser as
<p>1</p>
<p>2</p>
"3"
<p></p>