Skip to content

update zh/head.md #116

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
5 changes: 3 additions & 2 deletions zh/head.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

类似于资源注入,Head 管理遵循相同的理念:我们可以在组件的生命周期中,将数据动态地追加到渲染`上下文`(render context),然后在`模板`中的占位符替换为这些数据。

> 在 >=2.3.2 的版本,您可以通过 `this.$ssrContext` 来直接访问组件中的服务器端渲染上下文(SSR context)。在旧版本中,您必须通过将其传递给 `createApp()` 并将其暴露于根实例的 `$options` 上,才能手动注入服务器端渲染上下文(SSR context) - 然后子组件可以通过 `this.$root.$options.ssrContext` 来访问它。
> 在 2.3.2+ 的版本,您可以通过 `this.$ssrContext` 来直接访问组件中的服务器端渲染上下文(SSR context)。在旧版本中,您必须通过将其传递给 `createApp()` 并将其暴露于根实例的 `$options` 上,才能手动注入服务器端渲染上下文(SSR context) - 然后子组件可以通过 `this.$root.$options.ssrContext` 来访问它。

我们可以编写一个简单的 mixin 来完成标题管理:

Expand Down Expand Up @@ -34,7 +34,7 @@ const clientTitleMixin = {
}
}
}
// 可以通过 webpack.DefinePlugin 注入 VUE_ENV
// 可以通过 `webpack.DefinePlugin` 注入 `VUE_ENV`
export default process.env.VUE_ENV === 'server'
? serverTitleMixin
: clientTitleMixin
Expand Down Expand Up @@ -76,6 +76,7 @@ export default {
**注意:**

- 使用双花括号(double-mustache)进行 HTML 转义插值(HTML-escaped interpolation),以避免 XSS 攻击。

- 你应该在创建 `context` 对象时提供一个默认标题,以防在渲染过程中组件没有设置标题。

---
Expand Down