8000 第十二节课问题收集 · Issue #25 · FE-star/2019.03 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

第十二节课问题收集 #25

New issue

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

Open
caihuiji opened this issue Jun 3, 2019 · 2 comments
Open

第十二节课问题收集 #25

caihuiji opened this issue Jun 3, 2019 · 2 comments
Labels

Comments

@caihuiji
Copy link
Contributor
caihuiji commented Jun 3, 2019

No description provided.

@caihuiji caihuiji added the 问题 label Jun 3, 2019
@welldeng
Copy link
welldeng commented Jun 25, 2019

@caihuiji �老师,请问我在源码里看到updateChildComponent()方法有一段代码
// Any static slot children from the parent may have changed during parent's
// update. Dynamic scoped slots may also have changed. In such cases, a forced
// update is necessary to ensure correctness.
const needsForceUpdate = !!(
renderChildren || // has new static slots
vm.$options._renderChildren || // has old static slots
hasDynamicScopedSlot
)

// resolve slots + force update if has children
if (needsForceUpdate) {
vm.$slots = resolveSlots(renderChildren, parentVnode.context)
vm.$forceUpdate()
}

当组件嵌套组件的时候,父组件更新会强制更新子组件,这似乎很容易引起性能问题,特别是当页面是那种表单布局,因为布局的组件和表单的组件都是互相嵌套的,除了再把这些组件包装成一个新的组件还有没有其他办法能优化这个问题?

关于上节课vue-diff的部分我去把源码看了一遍,vue并不是收集所有patch然后再一次更新的,而是在diff的过程中不断的patch然后直接更新视图,貌似和react的有区别,react里面好像可以统一更新,而且还可以指定不更新子组件。

@welldeng
Copy link

这个格式我怎么调都调不好。。。将就看一下😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants
0