• react安装及使用


    一, 安装react脚手架

      1. 全局安装脚手架

        npm install -g create-react-app

      2. 创建我们react项目

        npx create-react-app shen-react(项目名不能有大写)

      3. 运行

        cd shen-react

        npm start

    二. 安装react路由

      1. 安装react-router-dom

      npm install react-router-dom --save-dev

    三, 创建项目中webpack配置文件

      npm run eject

      如果这步报错  运行   git add .          git commit -m 'init'

      然后在运行 npm run eject

    四, 安装less

      npm install less less-loader --save-dev 

      建议是用 yarn add less-loader@5.0.0

      修改配置文件 config/webpack.config.js

      

    // style files regexes 47行
    const cssRegex = /.css$/;
    const cssModuleRegex = /.module.css$/;
    const sassRegex = /.(scss|sass)$/;
    const sassModuleRegex = /.module.(scss|sass)$/;
    
    // 新加
    const lessRegex = /.less$/;
    const lessModuleRegex = /.module.less$/;
    //less 自定义 466行
    // 找 sassRegex 并列放在这个对象上面,
    { test: lessRegex, exclude: lessModuleRegex, use: getStyleLoaders({ importLoaders: 3, sourceMap: isEnvProduction && shouldUseSourceMap, }, 'less-loader' ), // Don't consider CSS imports dead code even if the // containing package claims to have no side effects. // Remove this when webpack adds a warning or an error for this. // See https://github.com/webpack/webpack/issues/6571 sideEffects: true, }, // Adds support for CSS Modules, but using SASS // using the extension .module.scss or .module.sass { test: lessModuleRegex, use: getStyleLoaders({ importLoaders: 3, sourceMap: isEnvProduction && shouldUseSourceMap, modules: { getLocalIdent: getCSSModuleLocalIdent, }, }, 'less-loader' ), }, //less end 自定义

      

  • 相关阅读:
    《瓦尔登湖》读书随笔
    Ubuntu下nginx+uwsgi+flask的执行环境搭建
    Android studio SweetAlert for Android
    mysql 主从不同步处理--数据库初始化
    Nginx学习——http配置项解析编程
    支付宝集分宝接口开发的相关问题解答
    解读刘强东关于人才的两个标准和5个层次
    oc35--自定义构造方法
    oc34--instancetype和id的区别
    oc33--构造方法2
  • 原文地址:https://www.cnblogs.com/shenjilin/p/13454490.html
Copyright © 2020-2023  润新知