Skip to Content
React学习手册
book

React学习手册

by Alex Banks, Eve Porcello
December 2017
Intermediate to advanced
329 pages
6h 9m
Chinese
China Electric Power Press Ltd.
Content preview from React学习手册
Redux
197
id: "2222e1p5-3abl-0p523-30e4-8001l8yf2222",
title: "Party Pink",
color: "#F142FF",
timestamp: "Thu Mar 10 2016 01:11:12 GMT-0800 (PST)"
})
console.log(
"Length of colors array after ADD_COLOR",
store.getState().colors.length
)
//
ADD_COLOR
之后,颜色数组的长度是
4
console.log(
"Color rating before RATE_COLOR",
store.getState().colors[3].rating
)
//
RATE_COLOR
之前,颜色评分值是
0
store.dispatch({
type: "RATE_COLOR",
id: "2222e1p5-3abl-0p523-30e4-8001l8yf2222",
rating: 5
})
console.log(
"Color rating after RATE_COLOR",
store.getState().colors[3].rating
)
//
RATE_COLOR
之后,颜色评分值是
5
这里我们创建了一个
Store
,并分发了一个添加新颜色的
Action
,随后的
Action
是用来
修改颜色评分的。控制台输出信息向我们展示了分发
Action ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React快速上手开发

React快速上手开发

Stoyan Stefanov
流畅的Python

流畅的Python

Luciano Ramalho
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787519814236