ล่าสุดการพัฒนาเว็บบทเรียน
 

AppMLทำอย่างไร


วิธีการสร้างแอพลิเคชัน AppML ใน 2 ขั้นตอนง่ายๆ


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="http://www.w3ii.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 = "http://www.w3ii.com/appml/2.0.3/appml.js"> เพิ่ม AppML หน้าเว็บของคุณ

appml ข้อมูล = "customers.js" เชื่อมต่อข้อมูล AppML (customers.js) ไปยัง HTML element (<table>)

ในกรณีนี้เราได้ใช้ไฟล์ JSON A: customers.js

appml ซ้ำ = "บันทึก" ซ้ำองค์ประกอบ HTML (<tr>) สำหรับแต่ละรายการ (records) ในวัตถุข้อมูล

ใช้ {{}} วงเล็บเป็นตัวยึดสำหรับข้อมูล AppML