Map 是一种键值对的集合,它通常用于需要快速查找和访问数据的情况,例如在处理大量数据时Set 是一种值的集合,其中每个值都是唯一的。它通常用于需要快速查找和去重数据的情况
对组件使用 v-model 的默认值是 modelValue
async function async1() { console.log('async1 start') await async2() console.log('async1 end') } async function async2() { console.log('async2 start') return new Promise((resolve) => { resolve() console.log('async2 end') }) } setTimeout(() => { console.log('setTimeout') }, 0) console.log('script start') async1() new Promise((resolve) => { resolve() console.log('promise1') }) .then(() => { console.log('then1') }) .then(() => { console.log('then2') }) console.log('script end')
// 结构大概是这样的 const arr = [ { id: 1, name: '部门1', pid: 0 }, { id: 2, name: '部门2', pid: 1 }, { id: 3, name: '部门2', pid: 1 }, { id: 4, name: '部门3', pid: 3 }, { id: 5, name: '部门4', pid: 4 }, ] // 输出 const tree = { id: 1, name: '部门1', pid: 0, children: [ { id: 2, name: '部门2', pid: 1, children: [], }, { id: 3, name: '部门2', pid: 1, children: [ { id: 4, name: '部门3', pid: 3, children: [ { id: 5, name: '部门4', pid: 4, children: [], }, ], }, ], }, ], }#前端实习面试##软件开发2023笔面经#