Skip to content

Commit d14575e

Browse files
author
Juanito Fatas
committed
docs(zh-hant): Translate FAQ: AJAX and APIs
1 parent c997479 commit d14575e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: content/docs/faq-ajax.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
---
22
id: faq-ajax
3-
title: AJAX and APIs
3+
title: AJAX APIs
44
permalink: docs/faq-ajax.html
55
layout: docs
66
category: FAQ
77
---
88

9-
### How can I make an AJAX call? {#how-can-i-make-an-ajax-call}
9+
### AJAX 怎麼用? {#how-can-i-make-an-ajax-call}
1010

11-
You can use any AJAX library you like with React. Some popular ones are [Axios](https://github.com/axios/axios), [jQuery AJAX](https://api.jquery.com/jQuery.ajax/), and the browser built-in [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
11+
React 可以搭配任何的 AJAX 專案。流行的專案有:[Axios](https://github.com/axios/axios)[jQuery AJAX](https://api.jquery.com/jQuery.ajax/) 以及瀏覽器內建的 [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
1212

13-
### Where in the component lifecycle should I make an AJAX call? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
13+
### 在組件的生命週期裡何時該使用 AJAX {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
1414

15-
You should populate data with AJAX calls in the [`componentDidMount`](/docs/react-component.html#mounting) lifecycle method. This is so you can use `setState` to update your component when the data is retrieved.
15+
應該要在 [`componentDidMount`](/docs/react-component.html#mounting) 方法裡。這樣才可以在收到資料時,使用 `setState` 來更新組件。
1616

17-
### Example: Using AJAX results to set local state {#example-using-ajax-results-to-set-local-state}
17+
### 範例:利用 AJAX 來設定狀態 {#example-using-ajax-results-to-set-local-state}
1818

19-
The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state.
19+
以下組件示範了如何在 `componentDidMount` 利用 AJAX 來取出組件當下的狀態。
2020

21-
The example API returns a JSON object like this:
21+
假設 API 回傳的 JSON 如下:
2222

2323
```
2424
{
2525
"items": [
2626
{ "id": 1, "name": "Apples", "price": "$2" },
2727
{ "id": 2, "name": "Peaches", "price": "$5" }
28-
]
28+
]
2929
}
3030
```
3131

0 commit comments

Comments
 (0)