实战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----------------------------------------------------------
手动webpack
https://zhuanlan.zhihu.com/p/45506253
创建两个文件store下的index和reducer
import {createStore} from 'redux'; import reducer from './reducer'; const store =createStore(reducer); export default store;
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]
相关文章
- React+dva+webpack+antd-mobile 实战分享(一)
- 【华为云技术分享】三大前端技术(React,Vue,Angular)探密(下)
- [React] Animate SVG Paths with Framer Motion
- [React] Use react styled system with styled components
- [React Suspense] Lazy load component with React suspense
- [React] Create an Auto Resizing Virtualized List with react-virtualized
- [React Fundamentals] Introduction to Properties
- [React] React Fundamentals: Build a JSX Live Compiler
- [React] Style a React component with styled-components
- [React Intl] Format Numbers with Separators and Currency Symbols using react-intl FormattedNumber
- [React Intl] Render Content with Markup Using react-intl FormattedHTMLMessage
- [React] Create an Auto Resizing Virtualized List with react-virtualized
- [React + Mobx] Mobx and React intro: syncing the UI with the app state using observable and observer
- [React] React Router: Querystring Parameters
- react路由v6讲解
- React的source code init时会自动检测Chrome dev tool的react extension装了没
- React的source code init时会自动检测Chrome dev tool的react extension装了没