AppML API
AppML API 定義了 AppML 的方法和屬性
方法和屬性可以做什麼?
使用方法和屬性,你可以
- 建立 AppML 應用程式
- 用資料填充應用程式
- 獲取應用程式資料以在你的網頁中使用
示例
new AppML() 建立一個新的 AppML 物件。
dataSource 設定 AppML 物件的資料來源。
getData() 獲取資料。
data.records 包含資料記錄。
你可以迴圈遍歷記錄並將內容顯示在 HTML 元素中
示例
// 建立一個 AppML 物件並獲取資料
myObj = new AppML();
myObj.dataSource = "https://w3schools.tw/appml/customers.php";
myObj.getData();
// 定位資料記錄
myArr = myObj.data.records;
len = myArr.length;
// 顯示記錄
for (i = 0; i < len; i++) {
txt += myArr[i].CustomerName + "<br>";
}
document.getElementById("demo").innerHTML = txt;
自己試試 »
結果
Alfreds Futterkiste
Berglunds snabbköp
Centro comercial Moctezuma
Ernst Handel
FISSA Fabrica Inter. Salchichas S.A.
Galería del gastrónomo
Island Trading
Königlich Essen
Laughing Bacchus Wine Cellars
Magazzini Alimentari Riuniti
North/South
Paris spécialités
Rattlesnake Canyon Grocery
Simons bistro
The Big Cheese
Vaffeljernet
Wolski Zajazd
一些 AppML 方法
方法 | 描述 |
---|---|
new AppML() | 建立一個新的 AppML 物件 |
run() | 執行一個應用程式物件 |
appml("name") | 返回具有指定名稱的 appml 物件 |
displayMessage(text) | 顯示指定的文字訊息。 |
setError(no, description) | 設定指定的錯誤和錯誤描述。 |
一些 AppML 屬性
屬性 | 描述 |
---|---|
appName | 應用程式名稱(容器 ID) |
container | 應用程式容器元素 |
controller | 應用程式控制器 |
data | 應用程式資料物件 |
dataSource | 應用程式資料來源 |
message | 應用程式訊息 |
一些資料物件屬性
屬性 | 描述 |
---|---|
data.model | 應用程式資料模型 |
data.records | 應用程式資料記錄 |