Skip to content

update zh/universal.md #118

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

Merged
merged 1 commit into from
Aug 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zh/universal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

## 组件生命周期钩子函数

由于没有动态更新,所有的生命周期钩子函数中,只有 `beforeCreate` 和 `created` 会在服务器端渲染(SSR)过程中被调用。这就是说任何其他声明周期钩子函数中的代码(例如 `beforeMount` 或 `mounted`),只会在客户端执行。
由于没有动态更新,所有的生命周期钩子函数中,只有 `beforeCreate` 和 `created` 会在服务器端渲染(SSR)过程中被调用。这就是说任何其他生命周期钩子函数中的代码(例如 `beforeMount` 或 `mounted`),只会在客户端执行。

此外还需要注意的是,你应该避免在 `beforeCreate` 和 `created` 生命周期时产生全局副作用的代码,例如在其中使用 `setInterval` 设置 timer。在纯客户端(client-side only)的代码中,我们可以设置一个 timer,然后在 `beforeDestroy` 或 `destroyed` 生命周期时将其销毁。但是,由于在 SSR 期间并不会调用销毁钩子函数,所以 timer 将永远保留下来。为了避免这种情况,请将副作用代码移动到 `beforeMount` 或 `mounted` 生命周期中。

Expand Down