AppML Nasıl Yapılır?


2 kolay adımda bir AppML Uygulaması nasıl oluşturulur .


1. HTML ve CSS Kullanarak Sayfa Oluşturun

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>

{{ }} köşeli ayraçlar , AppML verileri için yer tutuculardır.

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

CSS'yi kendi favori stil sayfanızla değiştirmekten çekinmeyin.


2. AppML'yi ekleyin

Sayfanıza veri eklemek için AppML'yi kullanın:

Örnek

<!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 Açıklaması:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> sayfanıza AppML ekler.

appml-data = "customers.js" , AppML verilerini (customers.js) bir HTML öğesine (<table>) bağlar.

Bu durumda bir JSON dosyası kullandık:

appml-repeat="records" , bir veri nesnesindeki her öğe (kayıtlar) için bir HTML öğesini (<tr>) tekrarlar.

{{ }} köşeli ayraçlar , AppML verileri için yer tutuculardır.