在 create-react(-native)-app 中使用antd-mobile

1、在添加antd-mobile组件之前,你应该先去安装yarn管理工具,yarn比起npm和cnpm来说,下载安装包的速度更快也更稳定;

2、通过cd命令进入到你的react项目中,然后通过yarn add antd-mobile命令来为你的项目添加antd-mobile组件;

3、通过yarn add babel-plugin-import less-loader postcss-pxtorem [email protected] --dev来为你的项目添加less依赖和使用svg图标,postcss可以为你自动补齐浏览器兼容前缀;

4、安装依赖成功以后,要对webpack做一些配置,这里不做过多赘述,详情参考webpack配置教程,你也可以直接复制项目中的webpack.config.dev.js文件;

5、通过yarn start或者npm start来启动你的项目;

6、到此为止,我们的整个项目前端部分的开发环境就搭建完毕了;

备注:

  • 当前项目针对的是移动端 ,所以我们还需要引入一下rem适配;
  • 博主使用的淘宝的flexible适配方案
  • http://www.w3cplus.com/mobile/lib-flexible-for-html5-layout.html
  • https://www.npmjs.com/package/postcss-px2rem

results matching ""

    No results matching ""