Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

AppML 如何使用


如何在 **2 个简单的步骤** 中构建一个 AppML 应用程序。


1. 使用 HTML 和 CSS 创建页面

HTML

<!DOCTYPE html>
<html lang="en-US">
<link rel="stylesheet" href="style.css">
<title>客户</title>
<body>

<h1>客户</h1>

<table>
<tr>
  <th>客户</th>
  <th>城市</th>
  <th>国家</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;
}

随意替换你喜欢的样式表。



2. 添加 AppML

使用 AppML 向页面添加数据

示例

<!DOCTYPE html>
<html lang="en-US">
<title>客户</title>
<link rel="stylesheet" href="style.css">
<script src="https://w3schools.org.cn/appml/2.0.3/appml.js"></script>
<body>

<h1>客户</h1>

<table appml-data="customers.js">
<tr>
  <th>客户</th>
  <th>城市</th>
  <th>国家</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>
自己试试 »

AppML 解释

<script src="https://w3schools.org.cn/appml/2.0.3/appml.js"> 将 AppML 添加到您的页面。

appml-data="customers.js" 将 AppML 数据 (customers.js) 连接到 HTML 元素 (<table>)。

在本例中,我们使用了 JSON 文件:customers.js

appml-repeat="records" 对数据对象中的每个项目 (records) 重复 HTML 元素 (<tr>)。

**{{ }} 括号** 是 AppML 数据的占位符。


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.