react 全家桶

react-antd

import { ConfigProvider, DatePicker, message } from 'antd';
// 由于 antd 组件的默认文案是英文,所以需要修改为中文
import zhCN from 'antd/es/locale/zh_CN';
import 'antd/dist/antd.css';

 

react-element

import { Button } from 'element-react';
import 'element-theme-default';

 


接口交互 

//Fetch请求数据  http 协议
Fetch(url,{
	method:'post',
	headers:{ 'Content-Type': 'application/json'},
	body: JSON.stringify(content)
}).then(res=>{
	//return Promise.reject('something went wrong!')
	return (res.ok)?res.json():Promise.reject({
        status: response.status,
        statusText: response.statusText
      });
}).catch(err=>{
	//console.log(err.status);
})

 

环境搭建 

  • npm i json-server -g  服务端搭建
  • npm i roadhog -g  客户端搭建
     

项目搭建

-- node_modules用于存放项目的依赖包,也就是构建这个React项目可能会用到的工具,
-- public /index.html 文件夹中是 index.html存放目录,也就是React根页面的所在地
-- src/index.js 中用于存放jsx文件,也就是项目开发中的主要区域
-- package.json用于记录项目信息,以及外部依赖包的导入信息等
--/server目录执行json-server db.json -w -p 3000

 

开发配置

npm run server

npm run dev

依赖卸载和安装

  • npm init
  • cnpm  --by=npm uninstall react
  • cnpm  --by=npm install react react-dom react-router  --save

指定版本安装

  • 在package.json 指定版本
  • 移除 node-modules
  • npm install 

版本调整

背景时,有一些插件对react版本的依赖时有要求的,

比如react版本在15.x react-router 在3.x 可以正常使用 用  4.x 则部分功能会报错

思路是先卸载指定依赖,然后安装时@指定版本

  • cnpm  --by=npm uninstall  react-router 
  • cnpm  --by=npm install  react-router@3.0.2  -S
{
  "name": "react-course",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "server": "cd server && json-server db.json -w -p 3000",
    "start": "roadhog server",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "antd": "^2.11.1",
    "axios": "^0.19.0",
    "babel-runtime": "^6.26.0",
    "babel-standalone": "^6.26.0",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-hot-loader": "^4.12.12",
    "react-router": "^3.0.2"
  }
}
"dependencies": {
  "@types/echarts": "0.0.6",
  "@types/history": "^4.5.1",
  "@types/html2canvas": "^0.5.35",
  "@types/isomorphic-fetch": "0.0.34",
  "@types/jquery": "^3.2.5",
  "@types/jquery.cookie": "^1.4.31",
  "@types/jspdf": "^1.1.31",
  "@types/lodash": "^4.14.105",
  "@types/loglevel": "^1.4.29",
  "@types/react": "^15.0.24",
  "@types/react-dom": "^0.14.23",
  "@types/react-redux": "^4.4.38",
  "@types/react-router": "^4.2.0",
  "@types/react-router-dom": "^4.0.4",
  "@types/react-router-redux": "^5.0.1",
  "@types/react-slick": "^0.14.1",
  "@types/redux": "^3.6.0",
  "@types/redux-actions": "^1.2.4",
  "@types/slick-carousel": "^1.6.32",
  "@types/webpack": "^3.8.5",
  "@types/webpack-env": "^1.13.0",
  "add-asset-html-webpack-plugin": "^2.1.2",
  "antd": "^2.11.1",
  "awesome-typescript-loader": "^3.4.1",
  "axios": "^0.16.2",
  "babel-polyfill": "^6.26.0",
  "body-parser": "^1.18.2",
  "cat_mathjax": "^1.0.0",
  "cat_mathquill_build": "^0.10.1",
  "cookie-parser": "^1.4.3",
  "echarts": "^3.6.2",
  "ejs": "^2.5.7",
  "es6-promise": "^4.1.0",
  "express": "^4.16.2",
  "fs": "0.0.1-security",
  "history": "^4.6.1",
  "html-pdf": "^2.2.0",
  "html2canvas": "^1.0.0-alpha.9",
  "http": "0.0.0",
  "immutability-helper": "^2.7.1",
  "isomorphic-fetch": "^2.2.1",
  "jquery": "^3.3.1",
  "jquery.cookie": "^1.4.1",
  "jspdf": "^1.3.5",
  "lodash": "^4.14.77",
  "loglevel": "^1.4.1",
  "make": "^0.8.1",
  "mathquill": "^0.10.1",
  "path": "^0.12.7",
  "prop-types": "^15.5.8",
  "react": "^15.5.4",
  "react-addons-css-transition-group": "^15.5.2",
  "react-dnd": "^5.0.0",
  "react-dnd-html5-backend": "^5.0.1",
  "react-dom": "^15.5.4",
  "react-redux": "^5.0.4",
  "react-router": "^4.2.0",
  "react-router-dom": "^4.1.1",
  "react-router-redux": "^5.0.0-alpha.6",
  "react-slick": "^0.14.11",
  "redbox-react": "^1.3.2",
  "redux-actions": "^2.0.2",
  "redux-saga": "^0.15.1",
  "redux-thunk": "^2.2.0",
  "reselect": "^3.0.1",
  "slick-carousel": "^1.6.0",
  "typescript": "2.8.1",
  "zhishinethtml2canvas": "^1.0"

 


参考链接

 

https://ant.design/components/button-cn/   anttd 官网

https://github.com/elemefe/element-react  element-react 官网

https://blog.csdn.net/awaw00/article/details/54693780 react 项目搭建

https://www.jianshu.com/p/0f8de32ad183 fetch  axios  ajax  交互

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值