Comment utiliser AppML
Comment créer une application AppML en 2 étapes faciles .
1. Créer une page en utilisant HTML et 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>
Les crochets {{ }} sont des espaces réservés pour les données AppML.
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;
}
N'hésitez pas à remplacer le CSS par votre propre feuille de style préférée.
2. Ajouter AppML
Utilisez AppML pour ajouter des données à votre page :
Exemple
<!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 expliqué :
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> ajoute AppML à votre page.
appml-data = "customers.js" connecte les données AppML (customers.js) à un élément HTML (<table>).
Dans ce cas, nous avons utilisé un fichier JSON :
appml-repeat="records" répète un élément HTML (<tr>) pour chaque élément (enregistrements) dans un objet de données.
Les crochets {{ }} sont des espaces réservés pour les données AppML.