]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
docs: add a note for use functional component (#922)
authorLee <55973914+PeterAlfredLee@users.noreply.github.com>
Thu, 6 May 2021 12:42:04 +0000 (20:42 +0800)
committerGitHub <noreply@github.com>
Thu, 6 May 2021 12:42:04 +0000 (14:42 +0200)
docs/api/index.md
docs/zh/api/index.md

index 99a6bedd8037b46dff50639f36c17da7d9156518..3ac5747e869f0d9a553bdbc337d3be4befefd3a5 100644 (file)
@@ -857,6 +857,18 @@ Route record that can be provided by the user when adding routes via the [`route
 
 - **See Also**: [Meta fields](../guide/advanced/meta.md)
 
+:::tip
+If you want to use a functional component, make sure to add a `displayName` to it.
+
+For example:
+```js
+const HomeView = () => h('div', 'HomePage')
+// in TypeScript, you will need to use the FunctionalComponent type
+HomeView.displayName = 'HomeView'
+const routes = [{ path: '/', component: HomeView }]
+```
+:::
+
 ## RouteRecordNormalized
 
 Normalized version of a [Route Record](#routerecordraw)
index 47b3eb33ab56823eeb10bb6c8959e2cf75dba603..91b33084c399024abcb1d383af4f9aa210b8ca25 100644 (file)
@@ -851,6 +851,18 @@ stringifyQuery?: (
 
 - **更多的内容请看**:[Meta 字段](../guide/advanced/meta.md)
 
+:::tip 注意
+如果你想使用函数式组件, 请确保在组件上添加一个 `displayName`。
+
+例如:
+```js
+const HomeView = () => h('div', 'HomePage')
+// 使用TypeScript时, 组件需要为 FunctionalComponent 类型
+HomeView.displayName = 'HomeView'
+const routes = [{ path: '/', component: HomeView }]
+```
+:::
+
 ## RouteRecordNormalized
 
 [路由记录](#routerecordraw)的标准化版本