Skip to content

Commit 852c297

Browse files
committed
docs: add cautions for deprecated html tags
1 parent 5a51912 commit 852c297

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

docs/guide/markdown.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,18 @@ Check out the [Built-in Components](../reference/components.md) for a full list
412412

413413
Check out the [Default Theme > Built-in Components](../reference/default-theme/components.md) for a full list of default theme built-in components.
414414
:::
415+
416+
## Cautions
417+
418+
### Deprecated HTML Tags
419+
420+
Deprecated HTML tags such as [\<center>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center) and [\<font>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font) are not allowed in VuePress markdown by default.
421+
422+
Those tags would not be recognized as native HTML tags by Vue template compiler. Instead, Vue will try to resolve those tags as Vue components, and obviously these components usually don't exist.
423+
424+
::: tip
425+
You should always avoid using deprecated HTML tags. However, if you want to use those tags anyway, you can set [compilerOptions.isCustomElement](https://v3.vuejs.org/api/application-config.html#compileroptions) to tell Vue template compiler not try to resolve them.
426+
427+
- For `@bundler-webpack`, set [vue.compilerOptions](../reference/bundler/webpack.md#vue)
428+
- For `@bundler-vite`, set [vuePluginOptions.template.compilerOptions](../reference/bundler/vite.md#vuepluginoptions)
429+
:::

docs/zh/guide/markdown.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,18 @@ module.exports = {
415415

416416
前往 [默认主题 > 内置组件](../reference/default-theme/components.md) 查看默认主题中的所有内置组件。
417417
:::
418+
419+
## 注意事项
420+
421+
### 已废弃的 HTML 标签
422+
423+
已废弃的 HTML 标签默认不允许在 VuePress 的 Markdown 中使用,比如 [\<center>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center)[\<font>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font) 等。
424+
425+
这些标签不会被 Vue 模板编译器识别成原生 HTML 标签。相反,Vue 会尝试将这些标签解析为 Vue 组件,而显然这些组件通常是不存在的。
426+
427+
::: tip
428+
你应该始终避免使用已废弃的 HTML 标签。不过,如果你无论如何都要使用这些标签的话,你可以通过设置 [compilerOptions.isCustomElement](https://v3.vuejs.org/api/application-config.html#compileroptions) 来告诉 Vue 模板编译器不要尝试解析它们。
429+
430+
- 对于 `@bundler-webpack` ,设置 [vue.compilerOptions](../reference/bundler/webpack.md#vue)
431+
- 对于 `@bundler-vite` ,设置 [vuePluginOptions.template.compilerOptions](../reference/bundler/vite.md#vuepluginoptions)
432+
:::

0 commit comments

Comments
 (0)