首页 > 其他 > 详细

7、react按需加载、装饰器配置

时间:2020-09-05 23:43:08      阅读:95      评论:0      收藏:0      [点我收藏+]

1、react按需加载、装饰器配置

使?第三?组件antd 

npm install antd --save

 1 import React, { Component } from ‘react‘
 2 import Button from ‘antd/lib/button‘
 3 import "antd/dist/antd.css"
 4 class App extends Component {
 5  render() {
 6  return (
 7  <div className="App">
 8  <Button type="primary">Button</Button>
 9  </div>
10  )
11  }
12 }
13 export default App

2、配置按需加载,装饰器

根?录创建config-overrides.js,一定要是根?录创建config-overrides名

npm install react-app-rewired customize-cra babel-plugin-import -D   按需加载

npm install -D @babel/plugin-proposal-decorators     装饰器

如有装饰器错误提示可以参照该博客操作:https://blog.csdn.net/qq_41576643/article/details/107933394

 

 1 const {
 2     override,
 3     fixBabelImports,
 4     addDecoratorsLegacy 
 5 } = require("customize-cra");
 6 
 7 module.exports = override(
 8  fixBabelImports("import", {//antd按需加载 libraryName: "antd",
 9  libraryName: "antd",
10  libraryDirectory: "es", //引入目录
11  style: "css"
12  }),
13  experimentalDecorators(),
14  addDecoratorsLegacy(),//配置装饰器
15 );

 

7、react按需加载、装饰器配置

原文:https://www.cnblogs.com/nothingness/p/13620129.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!