AppML- Anleitung


So erstellen Sie eine AppML-Anwendung in zwei einfachen Schritten .


1. Erstellen Sie eine Seite mit HTML und CSS

HTML

<!DOCTYPE html>
<html lang="en-US">
<link rel="stylesheet" href="style.css">
<title>Customers</title>
<body>

<h1>Customers</h1>

<table>
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr>
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>

Die Klammern {{ }} sind Platzhalter für AppML-Daten.

CSS

body {
  font: 14px Verdana, sans-serif;
}

h1 {
  color: #996600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border: 1px solid grey;
  padding: 5px;
  text-align: left;
}

table tr:nth-child(odd) {
  background-color: #f1f1f1;
}

Fühlen Sie sich frei, das CSS durch Ihr eigenes bevorzugtes Stylesheet zu ersetzen.


2. Fügen Sie AppML hinzu

Verwenden Sie AppML, um Ihrer Seite Daten hinzuzufügen:

Beispiel

<!DOCTYPE html>
<html lang="en-US">
<title>Customers</title>
<link rel="stylesheet" href="style.css">
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>

<h1>Customers</h1>

<table appml-data="customers.js">
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>

AppML erklärt:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> fügt Ihrer Seite AppML hinzu.

appml-data = "customers.js" verbindet AppML-Daten (customers.js) mit einem HTML-Element (<table>).

In diesem Fall haben wir eine JSON-Datei verwendet:

appml-repeat="records" wiederholt ein HTML-Element (<tr>) für jedes Element (records) in einem Datenobjekt.

Die Klammern {{ }} sind Platzhalter für AppML-Daten.