# note-simple **Repository Path**: wangcong00/note-simple ## Basic Information - **Project Name**: note-simple - **Description**: 一个简易的笔记项目 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-12 - **Last Updated**: 2024-12-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 1.启动服务 node server.js 2.启动前端 cd note-app npm run dev note-app 前端项目 server.js 后端项目 1、第一题(必选) 请给出下面这段代码的执行结果, 并写出分析过程; 如果在 async1() 改为 await async1() ,执行结果会改变吗?为什么? setTimeout(function() { console.log('setTimeout 1'); new Promise(function(resolve) { console.log('promise 1'); resolve(); }).then(function() { console.log('promise then') }) }) async function async1() { console.log( 'async1 start' ) await async2(); console.log( 'async1 end' ) await async3(); } async function async2() { console.log( 'async2' ) } async function async3() { console.log( 'async3' ) } console.log('eventLoop'); async1(); new Promise(function(resolve) { console.log('promise 2'); resolve(); }).then(function() { console.log('promise2 then') }); new Promise(function(resolve) { console.log('promise 4'); resolve(); }).then(function() { console.log('promise4 then') }); console.log('eventLoop end'); 事件循环的题目。先执行同步任务,在执行异步任务。 代码是由上至下执行得。不管同步还是异步,当遇到同步先执行,遇到异步任务先打开放到异步队列, 等待同步执行完成后,再去异步队列中查看,微任务优先级高于宏任务,先将异步队列中的任务执行完成,再看宏任务队列 eventLoop // 第一个同步任务 async1 start // async1 内的同步任务 async2 // 因为加了await 等待,函数执行完成 promise 2 // promise 是同步的,promise 中回调才是异步的 promise 4 // promise 是同步的,promise 中回调才是异步的 eventLoop end // 继续执行同步任务,本次的最后一个同步任务 async1 end // 因为同步任务优先级高,所以此时才输出 async3 // async1 中的方法,当同步执行完成才执行到这里 promise2 then // promise 微任务中的异步方法 promise4 then // promise 微任务中的异步方法 setTimeout 1 // 宏任务在微任务后执行 promise 1 // 包裹在宏任务中 promise then //包裹在宏任务里面的 promise 的异步方法 await async1() 的执行结果: eventLoop // 第一个同步任务 async1 start // 方法中的同步任务 async2 // 因为加了await 等待,函数执行完成 async1 end // 因为 async1加了await 它内部的任务都会先执行 async3 // 因为 async1加了await 它内部的任务都会先执行 promise 2 // promise 是同步的,promise 中回调才是异步的 promise 4 // promise 是同步的,promise 中回调才是异步的 eventLoop end //同步任务 promise2 then // 异步微任务 promise4 then // 异步微任务 setTimeout 1 // 宏任务在微任务后执行 promise 1 // setTimeout包裹的了,所以要等setTimeout打开才能执行到这个微任务 promise then //setTimeout包裹的了,promise 异步任务 2、第二题 开发一个简单的笔记管理应用:创建一个简单的笔记管理应用,能够让用户添加、查看、编辑、删除和搜索笔记,同时要求具有数据持久化和高效数据处理的功能。 * 创建基础的 HTML 页面结构,具体需求包括: a. 笔记列表区域。 b. 笔记内容显示和编辑区域。 c. 搜索框。 d. 添加笔记的按钮或输入区域。 * 使用 CSS 进行布局和样式设计,确保应用在不同设备上均具有良好的响应性和可用性。