From 60ace54944b416032097260cac7937933d24010b Mon Sep 17 00:00:00 2001 From: Jing Cui Date: Mon, 16 Jan 2017 16:16:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?documentation=EF=BC=9Amodify=20and=20fix=20?= =?UTF-8?q?3=20points?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1)默认脚手架生成的工程「egg-init egg-init egg-example --type=simple」中路由写到的/home了 2)this.ctx.curl(url, { dataType: 'json' })的返回值非promise对象,使用.then()会报错 3)需config中增加serverUrl、pageSize的值 --- docs/source/zh-cn/intro/quickstart.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/source/zh-cn/intro/quickstart.md b/docs/source/zh-cn/intro/quickstart.md index b6ceed4df7..4b0cf577d9 100644 --- a/docs/source/zh-cn/intro/quickstart.md +++ b/docs/source/zh-cn/intro/quickstart.md @@ -23,7 +23,7 @@ $ npm i ```bash $ npm run dev -$ open localhost:7001 +$ open localhost:7001/home ``` ## 逐步搭建 @@ -196,9 +196,9 @@ module.exports = app => { // parallel GET detail, see `yield {}` from co const newsList = yield Object.keys(idList).map(key => { const url = `${serverUrl}/item/${idList[key]}.json`; - return this.ctx.curl(url, { dataType: 'json' }).then(res => res.data); + return this.ctx.curl(url, { dataType: 'json' }); }); - return newsList; + return newsList.map(res => res.data); } } return NewsService; @@ -217,6 +217,15 @@ exports.list = function* newsList() { yield this.render('news/list.tpl', { list: newsList }); }; ``` +还需增加app/service/news.js中读取到的配置: + +```js +// config/config.default.js +config.news = { + pageSize: 5, + serverUrl: 'https://hacker-news.firebaseio.com/v0', + }; +``` ### 编写扩展 From 1b58b8caf1d4dbfbd8479594b3b8559e0d4bd18c Mon Sep 17 00:00:00 2001 From: Jing Cui Date: Mon, 16 Jan 2017 17:27:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/zh-cn/intro/quickstart.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/zh-cn/intro/quickstart.md b/docs/source/zh-cn/intro/quickstart.md index 4b0cf577d9..dddb723e30 100644 --- a/docs/source/zh-cn/intro/quickstart.md +++ b/docs/source/zh-cn/intro/quickstart.md @@ -217,14 +217,14 @@ exports.list = function* newsList() { yield this.render('news/list.tpl', { list: newsList }); }; ``` -还需增加app/service/news.js中读取到的配置: +还需增加 `app/service/news.js` 中读取到的配置: ```js // config/config.default.js config.news = { - pageSize: 5, - serverUrl: 'https://hacker-news.firebaseio.com/v0', - }; + pageSize: 5, + serverUrl: 'https://hacker-news.firebaseio.com/v0', +}; ``` ### 编写扩展