weex-ui是阿里出品的搭配weex使用的UI框架,为了开发weex,我就需要开始试着使用weex-ui,我们首先要将weex加载到我们的项目中去
第一步进入我们的项目中,然后打开CMD,输入:
npm i weex-ui@latest -S
这里开发文档上建议node.js版本号是 >= 8.0, 推荐使用 n 来进行版本管理,同时建议 npm 版本 >= 5,同时推荐使用较新版本的weex
然后让我们来安装babel-preset-stage-0 和 babel-plugin-component 插件,前者用于babel编译,后者用于优化 weex-ui 包的组件引用
npm i babel-plugin-component babel-preset-stage-0 -D
同时在项目目录中寻找到.babelrc文件,然后将其中内容修改为
{
"presets": ["es2015", "stage-0"],
"plugins": [
[
"component",
{
"libraryName": "weex-ui",
"libDir": "packages",
"style": false
}
]
]
}
直接复制使用即可,然后在我们的vue页面中,使用import引入我们需要使用的weex组件