React - antd-mobile

袁帅
2023-12-01

antd-mobile

// 下载组件库
1. cnpm install antd-mobile --save

// 下载依赖
npm i --save babel-plugin-import
npm i react-app-rewired@2.0.2-next.0 --save-dev


// 在项目根目录下定义加载配置的js模块: config-overrides.js

const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {
      config = injectBabelPlugin(['import', { libraryName: 'antd-mobile', style: 'css' }], config);
      return config;
};


修改配置package.json

// 原先
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

// 修改之后
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject"

 类似资料: