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

两个页面的fetch.ts返回数据混合 #64

Closed
Rainer-Yu opened this issue May 31, 2021 · 3 comments
Closed

两个页面的fetch.ts返回数据混合 #64

Rainer-Yu opened this issue May 31, 2021 · 3 comments

Comments

@Rainer-Yu
Copy link
Contributor

plugin-vue3/src/entry/client-entry.ts
image
fetch.ts 返回的数据合并进 asyncData 使用的是reactive 不必添加 .value包装 也不会丢失响应性

在 vue3当中 ref() 响应式 是带有 .value 包装的 reactive() 是通过proxy 实现的 无需 .value包装
带有 .value 还会在后续取值的操作上 重复写出 带有 .value 的代码

@zhangyuang
Copy link
Owner

那肯定是得加的啊,你除了考虑fetch.ts返回,还有直接修改asyncData的可能。如果我直接把asyncData赋值了一个新的obj,响应性就没了。如果加了.value就算你把整个.value赋值新的obj,响应性仍然存在

@zhangyuang
Copy link
Owner

ref: image

@Rainer-Yu
Copy link
Contributor Author

ssr-plugin-vue3\src\entry\client-entry.ts
image

现在的问题是 切换页面,之前页面fetch.ts返回的数据还存在于 asyncData.value 里面,导致两个页面的fetch.ts返回数据混合,是有意这样设计 还是?

@Rainer-Yu Rainer-Yu reopened this May 31, 2021
@Rainer-Yu Rainer-Yu changed the title fetch.ts 返回的 asyncData 不必添加 .value包装 也不会丢失响应性 两个页面的fetch.ts返回数据混合 May 31, 2021
This issue was closed.
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

2 participants