File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
类似于资源注入,Head 管理遵循相同的理念:我们可以在组件的生命周期中,将数据动态地追加到渲染` 上下文 ` (render context),然后在` 模板 ` 中的占位符替换为这些数据。
4
4
5
- > 在 >= 2.3.2 的版本,您可以通过 ` this.$ssrContext ` 来直接访问组件中的服务器端渲染上下文(SSR context)。在旧版本中,您必须通过将其传递给 ` createApp() ` 并将其暴露于根实例的 ` $options ` 上,才能手动注入服务器端渲染上下文(SSR context) - 然后子组件可以通过 ` this.$root.$options.ssrContext ` 来访问它。
5
+ > 在 2.3.2+ 的版本,您可以通过 ` this.$ssrContext ` 来直接访问组件中的服务器端渲染上下文(SSR context)。在旧版本中,您必须通过将其传递给 ` createApp() ` 并将其暴露于根实例的 ` $options ` 上,才能手动注入服务器端渲染上下文(SSR context) - 然后子组件可以通过 ` this.$root.$options.ssrContext ` 来访问它。
6
6
7
7
我们可以编写一个简单的 mixin 来完成标题管理:
8
8
@@ -34,7 +34,7 @@ const clientTitleMixin = {
34
34
}
35
35
}
36
36
}
37
- // 可以通过 webpack.DefinePlugin 注入 VUE_ENV
37
+ // 可以通过 ` webpack.DefinePlugin` 注入 ` VUE_ENV`
38
38
export default process .env .VUE_ENV === ' server'
39
39
? serverTitleMixin
40
40
: clientTitleMixin
@@ -76,6 +76,7 @@ export default {
76
76
** 注意:**
77
77
78
78
- 使用双花括号(double-mustache)进行 HTML 转义插值(HTML-escaped interpolation),以避免 XSS 攻击。
79
+
79
80
- 你应该在创建 ` context ` 对象时提供一个默认标题,以防在渲染过程中组件没有设置标题。
80
81
81
82
---
You can’t perform that action at this time.
0 commit comments