You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
<div>
|
|
<h1>你好,小怪兽</h1>
|
|
</div>
|
|
<div>
|
|
<button id="increment">+</button>
|
|
<button id="decrement">−</button>
|
|
<span>Counter: <span id="counterResult">0</span></span>
|
|
</div>
|
|
<div>
|
|
<button id="compute">Compute</button>
|
|
<span>结果: <span id="computeResult">(not started)</span></span>
|
|
</div>
|
|
<script type="module">
|
|
const ui = {};
|
|
document.querySelectorAll("[id]").forEach((e) => (ui[e.id] = e));
|
|
|
|
ui.increment.addEventListener("click", async () => {
|
|
ui.counterResult.textContent = await window.count(1);
|
|
});
|
|
ui.decrement.addEventListener("click", async () => {
|
|
ui.counterResult.textContent = await window.count(-1);
|
|
});
|
|
ui.compute.addEventListener("click", async () => {
|
|
ui.compute.disabled = true;
|
|
ui.computeResult.textContent = "(pending)";
|
|
ui.computeResult.textContent = await window.compute(6, 7);
|
|
ui.compute.disabled = false;
|
|
});
|
|
// 禁用右键菜单
|
|
document.addEventListener("contextmenu", (e) => e.preventDefault());
|
|
</script>
|
|
|