update
This commit is contained in:
@@ -12,3 +12,23 @@ function fakeFetchCourses() {
|
||||
// 3. 调用 fakeFetchCourses()
|
||||
// 4. 用 then 渲染课程列表
|
||||
// 5. 用 catch 处理错误
|
||||
const btn = document.getElementById("load-btn")
|
||||
const text = document.getElementById("status-text")
|
||||
const list = document.getElementById("course-list")
|
||||
|
||||
btn.addEventListener("click", function () {
|
||||
text.textContent = "加载中..."
|
||||
|
||||
fakeFetchCourses()
|
||||
.then(function (result) {
|
||||
text.textContent = "加载成功"
|
||||
const a = result.forEach(item => {
|
||||
const li = document.createElement("li")
|
||||
li.textContent = item
|
||||
list.appendChild(li)
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
list.textContent = "失败" + error
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user