AppML 下载
获取 appml.js、本地部署、版本选择与离线可用性。
两种引用方式
<!-- 方式一:CDN(需要外网) -->
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<!-- 方式二:本地(推荐用于正式项目) -->
<script src="js/appml.js"></script>The CDN is convenient but depends on the internet and on their version control: an upgrade or shutdown breaks your page. Production projects should always host it locally.
本地部署
# 用 curl 或浏览器另存
curl -o appml.js https://www.w3schools.com/appml/2.0.3/appml.jsmy-app/
├── index.html
├── js/
│ └── appml.js
├── models/
│ └── customers.xml
└── data/
└── customers.json版本选择
| Version | Notes |
|---|---|
| 1.x | 早期版本,API 与 2.x 不兼容 |
| 2.0.x | 目前文档主要对应的版本 |
| 未版本化路径 | 会随上游更新,不要用于生产 |
A versioned path (/2.0.3/appml.js) is more predictable: upstream releases cannot affect you, at the cost of manual upgrades.
离线验证
<script src="js/appml.js"></script>
<script>
window.addEventListener('load', () => {
if (typeof appml === 'undefined') {
document.body.insertAdjacentHTML('afterbegin',
'<p style="color:#c00">AppML 未加载,请检查 js/appml.js 路径</p>');
}
});
</script>A self-check saves a lot of debugging: when AppML fails to load the page is simply blank and the console shows only appml is not defined, easily mistaken for a model error.
许可证与来源
AppML is maintained by W3Schools with source and examples published on their site. Check the current licence before commercial use; teaching projects often change terms.
两种引用方式
<!-- 方式一:CDN(需要外网) -->
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<!-- 方式二:本地(推荐用于正式项目) -->
<script src="js/appml.js"></script>CDN 版省事但依赖外网,且版本由对方控制——对方升级或下线,你的页面就挂了。正式项目一律下载到本地。
本地部署
# 用 curl 或浏览器另存
curl -o appml.js https://www.w3schools.com/appml/2.0.3/appml.jsmy-app/
├── index.html
├── js/
│ └── appml.js
├── models/
│ └── customers.xml
└── data/
└── customers.json版本选择
| 版本 | 说明 |
|---|---|
| 1.x | 早期版本,API 与 2.x 不兼容 |
| 2.0.x | 目前文档主要对应的版本 |
| 未版本化路径 | 会随上游更新,不要用于生产 |
引用路径里带版本号(/2.0.3/appml.js)比不带更可控。带版本号时上游发新版本不会影响你,代价是要手动升级。
离线验证
<script src="js/appml.js"></script>
<script>
window.addEventListener('load', () => {
if (typeof appml === 'undefined') {
document.body.insertAdjacentHTML('afterbegin',
'<p style="color:#c00">AppML 未加载,请检查 js/appml.js 路径</p>');
}
});
</script>加一段自检能省掉大量排查时间。AppML 加载失败时页面通常只是空白,控制台也只有一句 appml is not defined,很容易以为是模型写错了。
许可证与来源
AppML 由 W3Schools 维护,源码与示例在其站点上公开。商用前请自行确认当前授权条款——这类教学项目的许可条件可能随时调整。