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 데이터의 자리 표시자입니다 .