From b870bdaac736bad00d1c0442e81581ae5a740a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=91=E8=A8=80?= <303152878@qq.com> Date: Mon, 16 Mar 2020 13:50:44 +0800 Subject: [PATCH] Update README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: babel-plugin-import 加载 --- docs/cn/README.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/cn/README.md b/docs/cn/README.md index 53213ae..e10f1d4 100644 --- a/docs/cn/README.md +++ b/docs/cn/README.md @@ -46,6 +46,34 @@ AppRegistry.registerComponent('HelloWorldApp', () => HelloWorldApp); import Label from 'teaset/components/Label/Label'; ``` +使用 babel-plugin-import 按需加载 +- yarn add -D babel-plugin-import +- babel 新增 plugins + +``` + [ + 'import', + { + libraryDirectory: 'components', + libraryName: 'teaset', + camel2DashComponentName: false, + customName: (name) => { + if (name === 'TopView') { + return 'teaset/components/Overlay/TopView'; + } else if (name === 'Theme') { + return 'teaset/themes/Theme'; + } else { + return `teaset/components/${name}/${name}`; + } + }, + }, + ] +``` + +``` +import { Label } from 'teaset'; +``` + ## 运行示例程序 从 github clone teaset 工程(或者下载 zip 文件): ``` @@ -153,4 +181,4 @@ container => () => {container}` 导航页面](./NavigationPage.md) # License -MIT \ No newline at end of file +MIT