<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                打開 SearchPage.js,在初始化狀態過程中增加一個message屬性: ~~~ this.state = { searchString: 'london', isLoading: false, message: '' }; ~~~ 在render方法中,在UI元素的最后加入: ~~~ <Text style={styles.description}>{this.state.message}</Text> ~~~ 這個Text用于向用戶顯示一些文本。 在 SearchPage 類中,在 _executeQuery()方法最后加入: ~~~ fetch(query) .then(response => response.json()) .then(json => this._handleResponse(json.response)) .catch(error => this.setState({ isLoading: false, message: 'Something bad happened ' + error })); ~~~ fetch 函數在?[Fetch API](https://fetch.spec.whatwg.org/)中定義,這個新的JavaScript規范被Firefox 39(Nightly版)以及Chrome 42(開發版)支持,它在XMLHttpRequest的基礎上進行了極大的改進。結果是異步返回的,同時使用了?[promise](http://www.html5rocks.com/en/tutorials/es6/promises/)規范,如果response中包含有效的JSON對象則將JSON對象的response成員(另一個JSON)傳到_handleResponse方法(后面實現)。 然后在 SearchPage類中增加方法: ~~~ _handleResponse(response) { this.setState({ isLoading: false , message: '' }); if (response.application_response_code.substr(0, 1) === '1') { console.log('Properties found: ' + response.listings.length); } else { this.setState({ message: 'Location not recognized; please try again.'}); } } ~~~ 如果查詢結果成功返回,我們重置 isLoading 屬性為false,然后打印結果集的總行數。 > 注意: Nestoria 有 不以1開頭的響應碼, 這些代碼都非常有用。例如202 和 200表示返回一個推薦位置的列表。當完成這個實例后,你可以嘗試處理這些返回碼,并將列表提供給用戶選擇。 保存,返回模擬器,按下Cmd+R ,然后搜索 ‘london’你將在控制臺看到一條消息,表示搜索到20條房子信息。嘗試輸入一個不存在的地名,比如 ‘narnia’ 你將看到如下信息: ![](http://cdn5.raywenderlich.com/wp-content/uploads/2015/03/react-narnia.png) 接下來我們在倫敦或者別的什么城市搜索20座房子。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看