-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
110 lines (101 loc) · 3.64 KB
/
index.html
File metadata and controls
110 lines (101 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<title>📚 jQuery / Fetch / Axios 對照練習</title>
<link rel="stylesheet" href="style.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<!-- ⚠️ Axios 鎖定版號(供應鏈防護)。請定期到 https://github.com/axios/axios/releases 確認最新穩定版 -->
<script src="https://cdn.jsdelivr.net/npm/axios@1.7.9/dist/axios.min.js"
crossorigin="anonymous"></script>
</head>
<body>
<header>
<h1>📚 書籍管理 — jQuery AJAX / Fetch / Axios 對照練習</h1>
<p class="hint">後端:<code>json-server --watch db.json --port 3000</code></p>
</header>
<!-- 統一新增區 -->
<section class="top-bar">
<form id="add-form">
<input type="text" name="title" placeholder="書名" required>
<input type="text" name="author" placeholder="作者" required>
<div class="btn-group">
<button type="button" data-method="jquery">➕ jQuery</button>
<button type="button" data-method="fetch">➕ Fetch</button>
<button type="button" data-method="axios">➕ Axios</button>
<button type="button" data-method="ky">➕ ky</button>
<button type="button" data-method="ofetch">➕ ofetch</button>
</div>
</form>
</section>
<div class="sync-bar">
<label class="auto-sync">
<input type="checkbox" id="auto-sync-toggle">
🔁 自動整理(操作後三欄自動 refetch)
</label>
</div>
<main class="grid">
<section class="col" data-col="jquery">
<div class="col-header">
<h2>🟦 jQuery AJAX</h2>
<button class="reload" title="重抓清單">🔄</button>
</div>
<ul class="book-list"></ul>
<pre class="log"></pre>
</section>
<section class="col" data-col="fetch">
<div class="col-header">
<h2>🟩 Fetch</h2>
<button class="reload" title="重抓清單">🔄</button>
</div>
<ul class="book-list"></ul>
<pre class="log"></pre>
</section>
<section class="col" data-col="axios">
<div class="col-header">
<h2>🟪 Axios</h2>
<button class="reload" title="重抓清單">🔄</button>
</div>
<ul class="book-list"></ul>
<pre class="log"></pre>
</section>
<section class="col" data-col="ky">
<div class="col-header">
<h2>🟦 ky</h2>
<button class="reload" title="重抓清單">🔄</button>
</div>
<ul class="book-list"></ul>
<pre class="log"></pre>
</section>
<section class="col" data-col="ofetch">
<div class="col-header">
<h2>🟧 ofetch</h2>
<button class="reload" title="重抓清單">🔄</button>
</div>
<ul class="book-list"></ul>
<pre class="log"></pre>
</section>
</main>
<!-- 書籍卡片模板:<template> 內容是惰性的(不會被渲染),由 shared.js clone 出來用 -->
<template id="book-template">
<li>
<div class="info">
<div class="title"></div>
<div class="author"></div>
</div>
<div class="actions">
<button class="edit">✏️</button>
<button class="del">🗑️</button>
</div>
</li>
</template>
<script src="js/shared.js"></script>
<script src="js/jquery-demo.js"></script>
<script src="js/fetch-demo.js"></script>
<script src="js/axios-demo.js"></script>
<!-- ky / ofetch 是 ESM-only,必須用 type="module" 載入 -->
<!-- ⚠️ 同樣鎖定版號,並請定期到 GitHub releases 確認最新穩定版 -->
<script type="module" src="js/ky-demo.js"></script>
<script type="module" src="js/ofetch-demo.js"></script>
</body>
</html>