Skip to content

Commit 79cdc6f

Browse files
topwoodsorrycc
authored andcommitted
fix typo, modal => model (#36)
1 parent af6d1db commit 79cdc6f

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

v1/zh-cn/tutorial/05-组件设计实践.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $ dva init
1313
现在,规范的样例模板我们已经有了,接下来我们一步一步添加自己的东西,看看如何完成我们的组件设计。
1414

1515
### 设置路由
16-
在准备好了 dva 的基本框架以后,需要为我们的项目配置一下路由,这里首先设置 Users Router Container 的访问路径,并且在 `/routes/` 下创建我们的组件文件 `User.jsx`
16+
在准备好了 dva 的基本框架以后,需要为我们的项目配置一下路由,这里首先设置 Users Router Container 的访问路径,并且在 `/routes/` 下创建我们的组件文件 `Users.jsx`
1717

1818
```jsx
1919
// .src/router.js
@@ -31,19 +31,19 @@ export default function({ history }) {
3131
```
3232

3333
```jsx
34-
// .src/routes/User.jsx
34+
// .src/routes/Users.jsx
3535
import React, { PropTypes } from 'react';
3636

37-
function User() {
37+
function Users() {
3838
return (
3939
<div>User Router Component</div>
4040
);
4141
}
4242

43-
User.propTypes = {
43+
Users.propTypes = {
4444
};
4545

46-
export default User;
46+
export default Users;
4747
```
4848

4949
其它路由可以自行添加,关于路由更多信息,可以查看 [react-router](https://github.com/reactjs/react-router) 获取更多内容。
@@ -139,9 +139,9 @@ import { Table, message, Popconfirm } from 'antd';
139139

140140
// 采用 stateless 的写法
141141
const UserList = ({
142-
total,
143-
current,
144-
loading,
142+
total,
143+
current,
144+
loading,
145145
dataSource,
146146
}) => {
147147
const columns = [{
@@ -170,7 +170,7 @@ const UserList = ({
170170
</p>
171171
),
172172
}];
173-
173+
174174
// 定义分页对象
175175
const pagination = {
176176
total,
@@ -210,7 +210,7 @@ import 'antd/dist/antd.css';
210210
其中我们发现,在我们设计 `UserList` 的时候,需要将分页信息 `total、current` 以及加载状态信息 `loading` 也传入进来,所以现在使用 `UserList` 就需要像这样:
211211

212212
```jsx
213-
<UserList
213+
<UserList
214214
current={current}
215215
total={total}
216216
dataSource={list}
@@ -286,6 +286,6 @@ export default Users;
286286
![image|400](https://zos.alipayobjects.com/rmsportal/HIDhLSNEgyNnVQD.png)
287287

288288
### 组件设计小结
289-
虽然我们上面实现的代码很简单,但是已经包含了组件设计的主要思路,可以看到 `UserList` 组件是一个很纯粹的 `Presentation Component`,所需要的数据以及状态是通过 `Users Router Component` 传递的,我们现在还是用的静态数据,接下来我们来看看如何在 modal 创建 __reducer__ 来将我们的数据抽象出来。
289+
虽然我们上面实现的代码很简单,但是已经包含了组件设计的主要思路,可以看到 `UserList` 组件是一个很纯粹的 `Presentation Component`,所需要的数据以及状态是通过 `Users Router Component` 传递的,我们现在还是用的静态数据,接下来我们来看看如何在 model 创建 __reducer__ 来将我们的数据抽象出来。
290290

291291
下一步,进入[添加Reducers](./06-添加Reducers.md)

v1/zh-cn/tutorial/06-添加Reducers.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
也许你在迷惑,为什么会叫做 reducer 这个名字,你或许知道 reduce 这个方法,在很多程序语言中,数组类型都具备 reduce 方法,而这个方法的功能就是聚合,比如下面这个在 javascript 中的例子:
77

88
```javascript
9-
[{x:1},{y:2},{z:3}].reduce(function(prev, next){
10-
return Object.assign(prev, next);
9+
[{x:1},{y:2},{z:3}].reduce(function(prev, next){
10+
return Object.assign(prev, next);
1111
})
1212
//return {x:1, y:2, z:3}
1313
```
@@ -79,7 +79,7 @@ export default {
7979
}
8080
```
8181

82-
我们把之前 `UserList` 组件中模拟的静态数据,移动到了 reducers 中,通过调用 `'users/query/success'` 这个 reducer,我们就可以将 Users Modal 的数据变成静态数据,那么我们如何调用这个 reducer,能够让这个数据传入 UserList 组件呢,接下来需要做的是:__关联Model__
82+
我们把之前 `UserList` 组件中模拟的静态数据,移动到了 reducers 中,通过调用 `'users/query/success'` 这个 reducer,我们就可以将 Users Model 的数据变成静态数据,那么我们如何调用这个 reducer,能够让这个数据传入 UserList 组件呢,接下来需要做的是:__关联Model__
8383

8484
### 关联 Model
8585

@@ -141,7 +141,7 @@ function mapStateToProps({ users }) {
141141
export default connect(mapStateToProps)(Users);
142142
```
143143

144-
在之前的 __组件设计__ 中讲到了 `Presentational Component` 的设计概念,在订阅了数据以后,就可以通过 `props` 访问到 modal 的数据了,而 UserList 展示组件的数据,也是 `Container Component` 通过 `props` 传递的过来的。
144+
在之前的 __组件设计__ 中讲到了 `Presentational Component` 的设计概念,在订阅了数据以后,就可以通过 `props` 访问到 model 的数据了,而 UserList 展示组件的数据,也是 `Container Component` 通过 `props` 传递的过来的。
145145

146146
组件和 model 建立了关联关系以后,如何在组件中获取 reduers 的数据呢,或者如何调用 reducers呢,就是需要发起一个 action。
147147

@@ -292,4 +292,3 @@ app.start(document.getElementById('root'));
292292
在这个例子中,我们在 合适的时机(进入 /users/ )发起(dispatch)了一个 action,修改了 model 的数据,并且通过 Container Components 关联了 model,通过 props 传递到 Presentation Components,组件成功显示。如果你想了解更多关于 reducers & actions 的信息,可以参看 [redux](http://redux.js.org/)
293293

294294
下一步,进入[添加Effects](./07-添加Effects.md)
295-

0 commit comments

Comments
 (0)