# 安装组件库

cnpm install -S dolphin-weex-ui
# 或
npm install -S dolphin-weex-ui
1
2
3

# 按需引入

借助 babel-plugin-component, 我们可以只引入需要的组件,以达到减少项目体积的目的。
首先,安装 babel-plugin-component:

    npm install -D babel-plugin-component
1

# 配置 .babelrc:


{
  "presets": ["es2015", "stage-0"],
  "plugins": [
    [
      "transform-runtime",
      {
        "helpers": false,
        "polyfill": false,
        "regenerator": true,
        "moduleName": "babel-runtime"
      }
    ],
    [
      "component",
      {
        "libraryName": "dolphin-weex-ui",
        "libDir": "packages",
        "style": false
      }
    ]
  ]
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

# 加载组件

  • 配置完成后,即可按需加载组件:
<script>
import { DofMinibar, DofButton } from 'dolphin-weex-ui'
export default {}
</script>
1
2
3
4
Last Updated: 10/31/2023, 3:47:50 PM