Skip to content

Commit 08f8f75

Browse files
committed
update
1 parent 6a5ff97 commit 08f8f75

File tree

5 files changed

+81
-39
lines changed

5 files changed

+81
-39
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"react-app-polyfill": "^1.0.2",
4848
"react-dev-utils": "^9.0.2",
4949
"react-dom": "^16.9.0",
50+
"react-redux": "^7.1.1",
51+
"redux": "^4.0.4",
5052
"resolve": "1.12.0",
5153
"resolve-url-loader": "3.1.0",
5254
"sass-loader": "7.2.0",

src/page/Counter/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { connect } from 'react-redux';
22
import React from 'react';
33

44
const mapStateToProps = (state) => {
5+
console.log('state对象', state);
56
return {
67
value: state.count
78
}
@@ -10,22 +11,24 @@ const mapStateToProps = (state) => {
1011
const mapDispatchToProps = {
1112
onIncreaseClick: () => {
1213
return {
13-
type: 'increase'
14+
type: 'increase',
15+
count: 10,
1416
}
1517
},
1618
onDecreaseClick: () => {
1719
return {
18-
type: 'decrease'
20+
type: 'decrease',
21+
count: 10,
1922
}
2023
},
2124
}
2225

2326
function Page({ value, onIncreaseClick, onDecreaseClick }) {
2427
return (
25-
<div>
28+
<div style={{ marginLeft: 50 }}>
2629
<h1>{value}</h1>
2730
<button onClick={onIncreaseClick}>+</button>
28-
<button onClick={onDecreaseClick}>-</button>
31+
<button style={{ marginLeft: 50 }} onClick={onDecreaseClick}>-</button>
2932
</div>
3033
)
3134
}

src/page/chinaMap/index.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ import React, {
44
import echarts from '../../echarts';
55

66

7-
import { log } from 'util';
8-
const provinceNameMap = {
9-
// 北京市: '北京',
10-
// 天津市: '天津',
11-
内蒙古自治区: '内蒙古',
12-
// 上海市: '上海',
13-
广西壮族自治区: '广西',
14-
// 重庆市: '重庆',
15-
西藏自治区: '西藏',
16-
宁夏回族自治区: '宁夏',
17-
新疆维吾尔自治区: '新疆',
18-
香港特别行政区: '香港',
19-
澳门特别行政区: '澳门',
20-
};
7+
// import { log } from 'util';
8+
// const provinceNameMap = {
9+
// // 北京市: '北京',
10+
// // 天津市: '天津',
11+
// 内蒙古自治区: '内蒙古',
12+
// // 上海市: '上海',
13+
// 广西壮族自治区: '广西',
14+
// // 重庆市: '重庆',
15+
// 西藏自治区: '西藏',
16+
// 宁夏回族自治区: '宁夏',
17+
// 新疆维吾尔自治区: '新疆',
18+
// 香港特别行政区: '香港',
19+
// 澳门特别行政区: '澳门',
20+
// };
2121

22-
function replaceProvinceName(key) {
23-
const val = provinceNameMap[key];
24-
return val || key;
25-
}
22+
// function replaceProvinceName(key) {
23+
// const val = provinceNameMap[key];
24+
// return val || key;
25+
// }
2626

27-
function randomData() {
28-
return Math.round(Math.random()*500);
29-
}
27+
// function randomData() {
28+
// return Math.round(Math.random()*500);
29+
// }
3030

3131
function initChart(inst, opt = {}) {
3232
if (!inst) {
@@ -162,23 +162,23 @@ const option = {
162162
trigger: 'item',
163163
formatter: function(params) {
164164
if (typeof(params.value)[2] == "undefined") {
165-
var toolTiphtml = ''
166-
for(var i = 0;i<toolTipData.length;i++){
167-
if(params.name==toolTipData[i].name){
165+
let toolTiphtml = ''
166+
for(let i = 0;i<toolTipData.length;i++){
167+
if(params.name===toolTipData[i].name){
168168
toolTiphtml += toolTipData[i].name+':<br>'
169-
for(var j = 0;j<toolTipData[i].value.length;j++){
169+
for(let j = 0;j<toolTipData[i].value.length;j++){
170170
toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
171171
}
172172
}
173173
}
174174
// console.log(convertData(data))
175175
return toolTiphtml;
176176
} else {
177-
var toolTiphtml = ''
178-
for(var i = 0;i<toolTipData.length;i++){
179-
if(params.name==toolTipData[i].name){
177+
let toolTiphtml = ''
178+
for(let i = 0;i<toolTipData.length;i++){
179+
if(params.name===toolTipData[i].name){
180180
toolTiphtml += toolTipData[i].name+':<br>'
181-
for(var j = 0;j<toolTipData[i].value.length;j++){
181+
for(let j = 0;j<toolTipData[i].value.length;j++){
182182
toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
183183
}
184184
}

src/page/reducer/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11

2-
const reducer = (state = { count: 0 }, action) => {
2+
const reducer = (state = { count: 0, name: 'Ming' }, action) => {
3+
return {
4+
...state,
5+
count: caculateNum(state.count, action),
6+
}
7+
};
8+
9+
function caculateNum( count = 0, action) {
310
switch (action.type) {
411
case 'increase':
5-
return { count: state.count + 1 };
12+
return count + action.count;
613
case 'decrease':
7-
return { count: state.count - 1 };
14+
return count - action.count;
815
default:
9-
return state;
16+
return count;
1017
}
11-
};
18+
}
1219
export default reducer;

yarn.lock

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4600,7 +4600,7 @@ hmac-drbg@^1.0.0:
46004600
minimalistic-assert "^1.0.0"
46014601
minimalistic-crypto-utils "^1.0.1"
46024602

4603-
hoist-non-react-statics@^3.1.0:
4603+
hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0:
46044604
version "3.3.0"
46054605
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
46064606
integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==
@@ -8161,6 +8161,23 @@ react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4:
81618161
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.10.2.tgz#984120fd4d16800e9a738208ab1fba422d23b5ab"
81628162
integrity sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA==
81638163

8164+
react-is@^16.9.0:
8165+
version "16.11.0"
8166+
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.11.0.tgz#b85dfecd48ad1ce469ff558a882ca8e8313928fa"
8167+
integrity sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==
8168+
8169+
react-redux@^7.1.1:
8170+
version "7.1.1"
8171+
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.1.1.tgz#ce6eee1b734a7a76e0788b3309bf78ff6b34fa0a"
8172+
integrity sha512-QsW0vcmVVdNQzEkrgzh2W3Ksvr8cqpAv5FhEk7tNEft+5pp7rXxAudTz3VOPawRkLIepItpkEIyLcN/VVXzjTg==
8173+
dependencies:
8174+
"@babel/runtime" "^7.5.5"
8175+
hoist-non-react-statics "^3.3.0"
8176+
invariant "^2.2.4"
8177+
loose-envify "^1.4.0"
8178+
prop-types "^15.7.2"
8179+
react-is "^16.9.0"
8180+
81648181
react-router-dom@^5.0.1:
81658182
version "5.1.2"
81668183
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.1.2.tgz#06701b834352f44d37fbb6311f870f84c76b9c18"
@@ -8288,6 +8305,14 @@ [email protected]:
82888305
dependencies:
82898306
minimatch "3.0.4"
82908307

8308+
redux@^4.0.4:
8309+
version "4.0.4"
8310+
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.4.tgz#4ee1aeb164b63d6a1bcc57ae4aa0b6e6fa7a3796"
8311+
integrity sha512-vKv4WdiJxOWKxK0yRoaK3Y4pxxB0ilzVx6dszU2W8wLxlb2yikRph4iV/ymtdJ6ZxpBLFbyrxklnT5yBbQSl3Q==
8312+
dependencies:
8313+
loose-envify "^1.4.0"
8314+
symbol-observable "^1.2.0"
8315+
82918316
regenerate-unicode-properties@^8.1.0:
82928317
version "8.1.0"
82938318
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz#ef51e0f0ea4ad424b77bf7cb41f3e015c70a3f0e"
@@ -9325,6 +9350,11 @@ svgo@^1.0.0, svgo@^1.2.2:
93259350
unquote "~1.1.1"
93269351
util.promisify "~1.0.0"
93279352

9353+
symbol-observable@^1.2.0:
9354+
version "1.2.0"
9355+
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
9356+
integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==
9357+
93289358
symbol-tree@^3.2.2:
93299359
version "3.2.4"
93309360
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"

0 commit comments

Comments
 (0)