0.1.0-alpha.2 • Published 2 years ago
tarojs-plugin-h5-native-components v0.1.0-alpha.2
背景
因为Taro不支持把组件编译为原生h5组件,此插件读取app.config.js中components的配置,通通打包成h5组件,方便h5应用使用。
支持版本 taro3.6.6
如何使用
- 本包不包含@trao/components,所以React项目自行安装
- 安装依赖
npm install tarojs-plugin-h5-native-components -D
- 启用插件,修改taro配置
{
"plugins": [
"tarojs-plugin-h5-native-components"
]
}
- package.json添加命令
{
"script": {
"build:h5-native-comps": "taro build --type h5-native-component"
}
}
- 执行命令
npm run build:h5-native-comps
如果app.config.js中components
是有配置的,那么正常会在dist目录下也会生成components
文件夹,直接复制到react即可。
6. 在项目入口文件添加如下代码
import { defineCustomElements } from '@tarojs/components/loader'
defineCustomElements();