簡體   English   中英

JavaScript:如何顯示來自此 api 數據的列表

[英]JavaScript : how to display list from this api data

我目前正在從事一個項目,我從一個站點獲取 API,並將其顯示在我的網頁上。

{
  "data": [{
  "truckplanNo":"TCTTV___0D010013",
  "truckplanType":"COLLECTION",
  "planArriveOriginTime":"2020-12-01T01:30:00.000000+07:00",
  "planDepartOriginTime":"2020-12-01T02:00:00.000000+07:00",
  "actualReleaseTime":"2020-11-30T21:46:56.000607+07:00",
  "jobSheetLine":2,
  "truckType":"10W",
  "truckLicense":"0717349/108",
  "orderLine":7,
  "updatedTimestamp":"2020-12-01T10:07:38.000575+07:00",
  "routeCategoryDesc":"SUPPLIER TO PLANT",
  "cbmLoadEff":37.80270691994573015,
  "flagReprint":false"
}]
}

如何獲取此數據以僅在 html 文本中顯示?

你可以這樣做:

const parsed = JSON.parse(json); // json is that json text
const data = parsed.data; // To get data key from json
data.forEach(cur => {
  console.log(cur); // This will print objects in data array one by one
});

而已!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM