美团2022秋招前端一面 二面
一面(一小时)
1. 介绍下vue的mixin
2. 写一下节流代码,问了一个场景题目:一个按钮,节流设置时间为3秒,现在我在第一次触发按钮绑定的事件后的2.2秒时又触发了这个事件,问会发生什么?
3. vue - computed 的get和set
4. css3的动画这么强,为什么还会有requestAnimationFrame?哪个性能好?为什么
5. 大文件本地缓存。情景:有一些接口数据需要缓存在本地,合起来大约几十兆,问该怎么办?
6. promise的api有哪些? 什么api成功失败都能返回结果?
7. 怎样获取cookie ?里面用的什么分隔符?封装一个获取cookie的代码思路
8. vue组件的keep-alive
9. css中margin上下外边距重叠问题
10.
var myObject = {
foo: 'bar',
func: function() {
var self = this;
console.log('outer func: this.foo = ' + this.foo)
console.log('outer func: self.foo = ' + self.foo)
(function() {
console.log(this);
console.log('inner func: this.foo = ' + this.foo)
console.log('inner func: self.foo = ' + self.foo)
}());
}
}
myObject.func(); 11. var a = {},
b = '123',
c = '456';
a[b] = 'b';
a[c] = 'c';
console.log(a[b]); 12. var a = {},
b = { key: '123' },
c = { key: '456' };
a[b] = 'b';
a[c] = 'c';
console.log(a[b]); 13. var obj = {
id1: '小明',
id2: '小华',
id3: '小红',
}
// 将上面的数据结构 化为数组内key-value形式 [ { value: id, label: 姓名 } ]
// 我的代码如下:
var arr = [];
for(var item of Object.keys(obj)) {
var obj1 = {
value: item,
label: obj[item]
}
arr.push(obj1)
}
console.log(arr);
// 这里到现在我都没弄明白,在Chrome里,这样写是会按【小明 小华 小红】顺序输出的,
// 但是在牛客编译器,输出的不仅是[[object, object], [object, object], [object, object]]
// 而且竟然是倒叙的,面试官问原因,回答不知道。。。 14. async function async1() {
console.log('async1 start')
await async2()
console.log('async1 end')
}
async function async2() {
console.log('async2')
}
console.log('script start')
setTimeout(function() {
console.log('settimeout')
})
async1()
new Promise(function(resolve) {
console.log('promise1')
resolve()
}).then(function() {
console.log('promise2')
})
console.log('script end') 15. VUE中以下代码生命周期顺序: <div> <C/> <B> <E/> <D/> </B> </div>16. parseQueryString方法,把url里的参数解析成对象
二面(57分钟)
1. 围绕项目展开,每个人都有自己的问法,无参考价值。
2. 高阶函数 柯里化介绍,特性是什么?写一个plus(1)(2)(3, 4)的函数,写完后提问:怎样缓存4这个参数呢?
3.
// 拍平数组
var a = [{
name: '1',
id: 1,
children: [
{
name: '1-1',
id: 2,
children: [
{
name: '1-1-1',
id: 3,
children: []
}
]
}
]
}] 4. function Foo(){
return new Date
}
const foo = new Foo()
// foo是个什么对象 5. new一个对象 发生了什么? 
