Skip to content
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

关于文档示例代码的小疑问 #332

Open
lie5860 opened this issue Dec 1, 2021 · 0 comments
Open

关于文档示例代码的小疑问 #332

lie5860 opened this issue Dec 1, 2021 · 0 comments

Comments

@lie5860
Copy link

lie5860 commented Dec 1, 2021

https://ssr.vuejs.org/zh/guide/data.html#%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%95%B0%E6%8D%AE%E9%A2%84%E5%8F%96-client-data-fetching

// 我们只关心非预渲染的组件
// 所以我们对比它们,找出两个匹配列表的差异组件
let diffed = false
const activated = matched.filter((c, i) => {
  return diffed || (diffed = (prevMatched[i] !== c))
})

其中这段代码的含义似乎是找到第一个变更的组件后返回其自身以及后续所有组件。 为什么要这样筛选而不是只筛选出存在差异的组件呢。

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

No branches or pull requests

1 participant