AppMLハウツー
2つの簡単なステップ でAppMLアプリケーションを構築する方法。
1.HTMLと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>
{{}}括弧は、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;
}
CSSをお好きなスタイルシートに自由に置き換えてください。
2.AppMLを追加します
AppMLを使用して、ページにデータを追加します。
例
<!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の説明:
<script src = "https://www.w3schools.com/appml/2.0.3/appml.js"> は、AppMLをページに追加します。
appml-data = "customers.js"は、AppMLデータ(customers.js)をHTML要素(<table>)に接続します。
この場合、JSONファイル
appml-repeat = "records" は、データオブジェクト内のアイテム(レコード)ごとにHTML要素(<tr>)を繰り返します。
{{}}括弧 は、AppMLデータのプレースホルダーです。