- Introduced a new script to check TypeScript lesson files for errors. - Created a main TypeScript file to render lessons and their details. - Added lesson definitions with starter and answer codes. - Implemented a user interface for navigating and running lessons. - Styled the application with CSS for a better user experience. - Updated README to reflect the new TypeScript section and usage instructions.
23 lines
661 B
JavaScript
23 lines
661 B
JavaScript
const lessons = [
|
|
{ title: "获取元素", done: false },
|
|
{ title: "修改 DOM", done: true },
|
|
];
|
|
|
|
function fakeLoadExtraLessons() {
|
|
return new Promise(function (resolve) {
|
|
setTimeout(function () {
|
|
resolve([
|
|
{ title: "事件委托", done: false },
|
|
{ title: "异步渲染", done: false },
|
|
]);
|
|
}, 900);
|
|
});
|
|
}
|
|
|
|
// 任务:
|
|
// 1. 获取页面里的关键元素
|
|
// 2. 写一个 renderLessons 函数,把 lessons 渲染到列表
|
|
// 3. 点击列表项时切换 done 状态
|
|
// 4. 提交表单时阻止默认提交,并新增课程
|
|
// 5. 点击加载按钮时显示加载状态,并把异步返回的课程追加到列表
|