We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createBody
new Vue( el: '#app')
执行 new Vue( el: '#app') 的最后一步就是:替换 #app 的 dom节点
替换通过 'appendChild' 和 ‘removeChild’ 来实现。
appendChild
removeChild
document
我们初始的 document 有一个子节点 body,这个 body 也是一个 Element ( 只是 ref 为 ‘root’,以标志为渲染树的根节点 ),也就是我们在 query 中可以返回 document.body,最后就是 document append 一个子树,因此加上 document.appendChild, document.removeChild 方法
document.appendChild
document.removeChild
appendChild (body) { if (body instanceof Element) { body.ref = BODY_REF this.body = body this.render() } }
return false
在执行 appendChild(body) 时,进行 render 的操作,进行一整颗树的渲染,(注意: 此后的更新是局部更新)
appendChild(body)
render
The text was updated successfully, but these errors were encountered:
No branches or pull requests
new Vue( el: '#app')
执行
new Vue( el: '#app')
的最后一步就是:替换 #app 的 dom节点替换通过 'appendChild' 和 ‘removeChild’ 来实现。
appendChild
: append 的是 vue 帮我们创建的子树removeChild
: remove 的是 原本存在 Dom Tree 的节点document
我们初始的 document 有一个子节点 body,这个 body 也是一个 Element ( 只是 ref 为 ‘root’,以标志为渲染树的根节点 ),也就是我们在 query 中可以返回 document.body,最后就是
document
append 一个子树,因此加上document.appendChild
,document.removeChild
方法document.appendChild
: append 的是一个 body,但是 document 应当只有一个 body,所以此时应该是替换操作document.removeChild
: remove 了 body 的操作似乎没有意义,直接return false
在执行
appendChild(body)
时,进行render
的操作,进行一整颗树的渲染,(注意: 此后的更新是局部更新)The text was updated successfully, but these errors were encountered: