【Javascript学习笔记】
可参照antdDesign官网文档中的资料 ClickHere 》
yarn add antd
App.js:
import React, { Component } from 'react';
import Button from 'antd/lib/button';
import './App.css';
class App extends Component {
render() {
return (
"App">
);
}
}
export default App;
src/App.css:
@import '~antd/dist/antd.css';
yarn add react-app-rewired --dev
/* package.json */
"scripts": {
- "start": "react-scripts start", + "start": "react-app-rewired start", - "build": "react-scripts build", + "build": "react-app-rewired build", - "test": "react-scripts test --env=jsdom", + "test": "react-app-rewired test --env=jsdom", }
在项目根目录创建一个 config-overrides.js 用于修改默认配置
module.exports = function override(config, env) {
// do stuff with the webpack config...
return config;
};
yarn add babel-plugin-import --dev
修改 config-overrides.js:
+ const { injectBabelPlugin } = require('react-app-rewired');
module.exports = function override(config, env) {
+ config = injectBabelPlugin(['import', { libraryName: 'antd', libraryDirectory: 'es', style: 'css' }], config);
return config;
};
src/App.css 里全量添加的 @import ‘~antd/dist/antd.css’;
各模块代码改写参考
- import Button from 'antd/lib/button';
+ import { Button } from 'antd';
(github:KuanG97) 下载实战代码 ClickHere》
全部React学习笔记的目录 Click Here>>
全部Javascript学习笔记的目录 Click Here>>
Less学习笔记 Click Here>>
安利一波前端开发推荐使用的工具 Click Here>>
github各类实战练习源码下载 Click Here>>
如果你觉得我的东西能帮到你,无限欢迎给我的github库点个收藏Star~0v 0~