AppML Hoe om


Hoe om 'n AppML-toepassing in 2 maklike stappe te bou .


1. Skep 'n bladsy deur HTML en CSS te gebruik

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 {{ }} hakies is plekhouers vir AppML-data.

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;
}

Vervang gerus die CSS met jou eie gunsteling stylblad.


2. Voeg AppML by

Gebruik AppML om data by jou bladsy te voeg:

Voorbeeld

<!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 verduidelik:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> voeg AppML by jou bladsy.

appml-data = "customers.js" verbind AppML-data (customers.js) aan 'n HTML-element (<tabel>).

In hierdie geval het ons 'n JSON-lêer gebruik:

appml-repeat="records" herhaal 'n HTML-element (<tr>) vir elke item (rekords) in 'n data-objek.

Die {{ }} hakies is plekhouers vir AppML-data.