選單
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

AppML 資料


AppML 的 **主要** 目的在於為 HTML 頁面提供 **資料**。


連線 AppML 到資料

  • AppML 可以顯示來自變數的資料
  • AppML 可以顯示來自檔案的資料
  • AppML 可以顯示來自資料庫的資料

AppML 使用 JavaScript 物件

分離 HTML 和資料的一種常見方法是將資料儲存在 JavaScript 物件中。

示例

<table appml-data="dataObj">
<tr>
  <th>客戶</th>
  <th>城市</th>
  <th>國家</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

<script>
var dataObj = {
"records":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds snabbköp","City":"Luleå","Country":"Sweden"},
{"CustomerName":"Blauer See Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel père et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bólido Comidas preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus Comidas para llevar","City":"Buenos Aires","Country":"Argentina"},
{"CustomerName":"Centro comercial Moctezuma","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"}
]};
</script>
自己試試 »


AppML 使用 JSON 檔案

另一種分離 HTML 和資料的方法是將資料儲存在 JSON 檔案中。

customers.js

{
"records":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds snabbköp","City":"Luleå","Country":"Sweden"},
{"CustomerName":"Blauer See Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel père et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bólido Comidas preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus Comidas para llevar","City":"Buenos Aires","Country":"Argentina"},
{"CustomerName":"Centro comercial Moctezuma","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"}
]
}

使用 AppML,您可以在 appml-data 屬性中將 JSON 檔案指定為資料來源。

示例

<table appml-data="customers.js">
<tr>
  <th>客戶</th>
  <th>城市</th>
  <th>國家</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>
自己試試 »

AppML 使用資料庫

藉助一點 Web 伺服器的幫助,您可以為您的應用程式提供 SQL 資料。

此示例使用 PHP 從 MySQL 資料庫讀取資料。

示例

<table appml-data="https://w3schools.tw/appml/customers.php">
<tr>
  <th>客戶</th>
  <th>城市</th>
  <th>國家</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>
自己試試 »

AppML 的強大功能

您即將發現 AppML 的強大功能。

AppML 可以為您提供用於

  • 超級簡單的 HTML 應用程式開發
  • 超級簡單的建模、原型設計和測試

您可以在一個 HTML 頁面中放入任意多個 AppML 應用程式。

AppML 不會干擾頁面的其他部分。

您擁有完全的 HTML、CSS 和 JavaScript 自由。

AppML 可用於開發全規模的 CRUD Web 應用程式。

CRUD:Create(建立)、Read(讀取)、Update(更新)、Delete(刪除)。

 要發現 AppML 的強大功能:檢視 AppML 演示


×

聯絡銷售

如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com

報告錯誤

如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com

W3Schools 經過最佳化,旨在方便學習和培訓。示例可能經過簡化,以提高閱讀和學習體驗。教程、參考資料和示例會不斷審查,以避免錯誤,但我們無法保證所有內容的完全正確性。使用 W3Schools 即表示您已閱讀並接受我們的使用條款Cookie 和隱私政策

版權所有 1999-2024 Refsnes Data。保留所有權利。W3Schools 由 W3.CSS 提供支援