示例工程 13-esm
13-esm/01-live-bindings/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>13 · ESM 活绑定</title>
</head>
<body>
<p>打开 Console 查看导入绑定如何随模块内部状态更新。</p>
<script type="module">
import { run, liveCount, inc, namespaceView } from './main.js';
run();
inc();
console.log('调用方直接读 liveCount =>', liveCount);
namespaceView().then((v) => console.log('命名空间视图 =>', JSON.stringify(v)));
</script>
</body>
</html>