zoukankan      html  css  js  c++  java
  • 实战build-react(一)

    https://www.jianshu.com/p/34468f13263c(copy)  目录结构

    一、安装

    npm install -g create-react-app

    二、创建react应用

    create-react-app 项目名称

    进入项目文件

    npm start   或 yarn

    然后chrome浏览器网上应用安装

    React Developer Tools和Redux DevTools

    https://blog.csdn.net/lengyoumo/article/details/80336922(copy)

    yarn --version

    如果没有

    安装方式:npm install yarn -g

    如果有

    安装redux

    yarn add redux

    //---------------------------------------------------选择性执行,不是必要的,有些项目需要-----------------------------------------------------------

    此时没有webpack.config.js文件,然后执行npm run eject暴露webpack.config.js文件,在config文件夹里

    但是有缺点,执行后所有开发环境的模块包都加进了运行环境里了

    或者可以尝试https://blog.csdn.net/qq_42190134/article/details/88528852(copy)

    大神指导

    https://blog.csdn.net/qq_32842925/article/details/83375791(copy)

    npm start #运行开发环境服务
    npm run build #将项目打包捆绑成用于生产环境的静态文件
    npm test #运行测试文件
    npm run eject # ↵
    #将所有工具和包移动并将其配置为项目的依赖,这样会把这些文件都差到package.json文件的dependences下
    #为的是开发时使用了自定义的第三方库能被准确标记。

     //---------------------------------------------------end----------------------------------------------------------

    创建两个文件store下的index和reducer

    //store/index.js
    import {createStore} from 'redux';
    import reducer from './reducer';
    const store =createStore(reducer);

    export default store;//store/reducer
    .js
    const defaultState={
    texts:'',
    list:[1,2]
    };
    export default (state=defaultState,action)=>{
    return state;
    }
    yarn add axios 或 npm install axios --save
    yarn add <package...>

    This will install one or more packages in your dependencies.

    yarn add <package...> [--dev/-D]

    Using --dev or -D will install one or more packages in your devDependencies.

    yarn add <package...> [--peer/-P]

    Using --peer or -P will install one or more packages in your peerDependencies.

    yarn add <package...> [--optional/-O]

    Using --optional or -O will install one or more packages in your optionalDependencies.

    yarn add <package...> [--exact/-E]
  • 相关阅读:
    10月23日总结
    10月22日总结
    10月21日总结
    使用Sklearn进行股票异常分析
    10月20日总结
    10月19日总结
    10月18日总结
    CF482E ELCA
    ERROR: Error installing mysql2: ERROR: Failed to build gem native extension [@Ubuntu 15.04]
    在Deepin 20.2系统中换源并全新图解安装MySQL数据库
  • 原文地址:https://www.cnblogs.com/dianzan/p/10815202.html
Copyright © 2011-2022 走看看