From 48940ab3ed0a4dd94441a7d80547b844ab32c909 Mon Sep 17 00:00:00 2001 From: caihuanyu Date: Mon, 11 Nov 2019 21:55:28 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=BB=84=E4=BB=B6=E5=B1=9E=E6=80=A7=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide/custom-component.md | 36 +++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/guide/custom-component.md b/docs/guide/custom-component.md index 284a000b5..29d286843 100644 --- a/docs/guide/custom-component.md +++ b/docs/guide/custom-component.md @@ -23,6 +23,37 @@ export default () => ( ## 注意事项 +请按照自定义组件的定义方式声明属性(并非所有组件都采用驼峰的方式命名属性)。 + +**错误:** + +```js +import React from 'react'; +import { View } from 'remax/alipay'; +import VantIcon from 'vant-weapp/dist/icon'; + +export default () => ( + + {/** vant-weapp 中 icon 的属性定义为 class-prefix,所以应遵循其命名规则 */} + + +); +``` + +**正确:** + +```js +import React from 'react'; +import { View } from 'remax/alipay'; +import VantIcon from 'vant-weapp/dist/icon'; + +export default () => ( + + + +); +``` + 对于带有具名 `slot` 的组件,具名 `slot` 部分的最外层只能用 `View` 组件。 **错误:** @@ -59,7 +90,6 @@ export default () => ( 不能在小程序自定义组件上使用 “Spread Attributes”。 - **错误:** ```js @@ -79,7 +109,7 @@ export default () => { ); -} +}; ``` **正确:** @@ -97,5 +127,5 @@ export default () => { ); -} +}; ```