# 基于 taro 的多端 UI 组件库

## 特性

- 目前只支持 h5、微信小程序、抖音小程序，其他端未得到验证
- node 16

## 使用

```bash
yarn add taro-react-uilib
```

```bash
npm install taro-react-uilib
```

## 配置

`config/index.js`

```js
const config = {
  // 其他配置
  ...
  h5.esnextModules: ['taro-uilib']
  // 其他配置
  ...
}
```

## 按需加载

### 首先引入 babel-plugin-import

```bash
yarn add babel-plugin-import -D
```

### 配置 babel-plugin-import 在 babel-config.js 里

```js
{
  plugins: [
    [
      'import',
      {
        libraryName: 'taro-react-uilib',
        customName: name => {
          const finalName = name.replace(/XH/, '')
          return `taro-react-uilib/dist/components/${finalName}`
        },
        camel2DashComponentName: false,
        style: name => {
          const componentsName = name.split('/').pop().toLocaleLowerCase()
          return `taro-react-uilib/dist/styles/components/${componentsName}.scss`
        }
      },
      'taro-react-uilib'
    ]
    // others....
    ...
  ]
}
```
