react 移动端使用antd mobile ui库

吕新
2023-12-01
1、安装
	cnpm install antd-mobile --save
	cnpm install babel-plugin-import --save-dev
	cnpm install react-app-rewired customize-cra --save-dev
	
2、设置按需加载和按需打包
	(1)在项目根目录创建(与src同级),config-overrides.js文件
	
		const { override, fixBabelImports } = require('customize-cra');
			module.exports = override(
			    fixBabelImports('import', {
			    libraryName: 'antd-mobile',
			    style: 'css',
			 }),
		);
	(2)修改package.json命令为
	
		  "scripts": {
		    "start": "react-app-rewired start",
		    "build": "react-app-rewired build",
		    "test": "react-app-rewired test --env=jsdom",
		    "eject": "react-scripts eject"
		  }
		  
3、配置less和主题样式与之前的antd一样

4、重新运行项目
 类似资料: