ऐपएमएल कैसे करें
2 आसान चरणों में AppML एप्लिकेशन कैसे बनाएं ।
1. HTML और CSS का उपयोग करके एक पेज बनाएं
एचटीएमएल
<!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 डेटा के लिए प्लेसहोल्डर हैं ।
सीएसएस
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;
}
सीएसएस को अपनी पसंदीदा स्टाइल शीट से बदलने के लिए स्वतंत्र महसूस करें।
2. ऐपएमएल जोड़ें
अपने पेज में डेटा जोड़ने के लिए 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>
ऐपएमएल समझाया:
<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 डेटा के लिए प्लेसहोल्डर हैं ।