zoukankan      html  css  js  c++  java
  • React--后台管理系统--项目框架的搭建

    设置淘宝镜像

    初始化项目

    yarn init -y npm init -y

    下载项目的所有声明的依赖

    yarn npm install yarn与npm 使用效果相同

    项目及开发

    使用create-react-app(脚手架)搭建项目

    npm install -g creact-react-app 全局下载工具

    creact-react-app react-admin 下载模板项目,名称为react-admin

    cd react-admin

    npm start 访问localhost:3000

    1.下载组件库包 yarn add antd

    2.实现组件的按需打包

    1)下载依赖模块 yarn add react-app-rewired customize-cra babel-plugin-import

    2)定义加载配置的js模块:config-overrides.js const {override, fixBabelImports} = require('customize-cra');

    module.exports = override(

    // 针对antd实现按需打包,根据import来打包(使用的babel-plugin-import)名字只需import引入即可

    fixBabelImports('import', {

      libraryName: 'antd',

      libraryDirectory: 'es',

      style: 'css', // 自动打包相关的样式

    }),

    );

    3)修改配置:package.json--删掉原来的配置

    "scripts": {

    "start": "react-app-rewired start",

    "build": "react-app-rewired build",

    "test": "react-app-rewired test",

    "eject": "react-scripts eject" },

    删掉下面的--下面的不会读取config-overrides.js文件--不会按需加载

    "scripts": { "start": "react-scripts start",

    "build": "react-scripts build",

    "test": "react-scripts test",

    "eject": "react-scripts eject" },

    这样可以注释掉index引入的全部样式

    // import 'antd/dist/antd.min.css' // 引入antdcss样式注释掉,按需加载

    自定义antd主题

    下载工具包 yarn add less less-loader

    修改config-overrides.js

    const {override, fixBabelImports, addlessLoader} = require('customize-cra');

    module.exports = override( // 针对antd实现按需打包,根据import来打包(使用的babel-plugin-import)名字只需import引入即可 fixBabelImports('import', {

    libraryName: 'antd',

    libraryDirectory: 'es',

    style: true, // 自动打包相关的样式 }),

     addLessLoader({
        javascriptEnabled: true,
        modifyVars: {'@primary-color': '#1DA57A'}, //颜色
     }),
    

    );

    引入路由

    下载路由包 yarn add react-router-dom

  • 相关阅读:
    vs2010配置驱动开发
    寒假训练 npuctf_2020_bad_guy(11/250)利用overlap与fastbin attack来篡改fd指针,从而通过stdout达到泄露libc
    寒假训练 [OGeek2019]bookmanager(10/250)
    寒假训练 npuctf_2020_level2(9/250)将heap分配到bss上,从而满足程序条件
    寒假训练 npuctf_2020_level2(8/250)修改ebp链来间接修改返回地址
    Windows XP源码跟踪
    寒假训练 houseoforange_hitcon_2016(7/250)
    寒假训练 jarvisoj_level6_x64(6/250)
    寒假训练 de1ctf_2019_weapon(5/250)
    glibc源码逆向——fwrite函数
  • 原文地址:https://www.cnblogs.com/fdxjava/p/11747890.html
Copyright © 2011-2022 走看看