高级农民
- 积分
- 1197
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2019-3-11
- 最后登录
- 1970-1-1
|
2019(4-6月) FrontEndEng 本科 实习@阿里巴巴 - 网上海投 - 技术电面 Onsite | Fail | 其他
注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
1. 前端常见跨域解决方案. ----
1、 通过jsonp跨域
2、 document.domain + iframe跨域
3、 location.hash + iframe
4、 window.name + iframe跨域
5、 postMessage跨域
6、 跨域资源共享(CORS)
7、 nginx代理跨域
8、 nodejs中间件代理跨域
9、 WebSocket协议跨域
. From 1point 3acres bbs
2.你提到了jsonp,它和json的区别是什么
其实json和jsonp本质上都是字符串,只是jsonp是外层包裹了一层函数。
jsonp的原理就是通过script的src,将函数作为src请求地址的参数来传递数据,所以jsonp只有get一种传输方式。
下面是jsonp的数据交互,首先定义一个回调函数,定义dataType类型为jsonp,将函数作为参数传输给后台,它与json相比是多了一层函数。 .1point3acres
3。如何知道jsonp后端的函数返回了?
.
就答了addeventlistener,然后面试官问还有别的吗,我说不知道,然后被科普了正则运算。。
.--.
4.前端里怎么添加类名:
- select.classlist.add("xxx")
复制代码 follow-up 还有其他的吗?
- var classVal = document.getElementById("id").getAttribute("class");
. Χ - . 1point3acres.com
- //删除的话
- classVal = classVal.replace("someClassName","");
- document.getElementById("id").setAttribute("class",classVal );
- //添加的话
- classVal = classVal.concat(" someClassName");
- document.getElementById("id").setAttribute("class",classVal );
复制代码
. Χ
5.能不能添加一个功能,没有这个class的时候再加呢
- if($('div').is('.class')){
- $('div').addClass('class');
- }
复制代码
还有吗?
- if (!p.classList.contains('classname')) {
- p.className += ' ' + 'classname';
- }
复制代码
.
6.css垂直居中和水平居中. 1point 3acres
- 第一种
- #container{
- position:relative;.1point3acres
- }
-
- #center{. Waral dи,
- width:100px;
- height:100px;
- position:absolute;
- top:50%;
- left:50%;
- transform: translate(-50%,-50%);
- }.google и
-
- 第二种
- #container{
- position:relative;
- }
-
- #center{
- width:100px;. check 1point3acres for more.
- height:100px;
- position:absolute;. Χ
- top:50%;-baidu 1point3acres
- left:50%;
- margin:-50px 0 0 -50px;
- }
-
- 第三种
- #container{
- position:relative;. 1point3acres
- }
-
- #center{-baidu 1point3acres
- position:absolute;
- margin:auto;
- top:0;. From 1point 3acres bbs
- bottom:0;
- left:0;
- right:0;
- }
-
- 第四种 flex
- #container{
- display:flex;
- justify-content:center;
- align-items: center;
- }
-
复制代码
. 1point3acres.com
7.怎么使一个边框有两种颜色?
这题不会。。。到最后都没听懂什么意思,我说用border double,他问怎么double,我说没用过不知道。 8.嵌套的数组扁平化(多维数组变成一维数组)
- function parseArr(arr,res){
- var i=0;.1point3acres
- for(i=0;i<arr.length;i++){. Χ
- if(arr[i] instanceof Array){
- parseArr(arr[i],res);
- }else{
- res.push(arr[i]);
- }
- }
- }
复制代码
- var newArr=arr.toString().split(',').map(function(ele){
- return +ele;
- });
复制代码
9.你提到了tostring(),为什么它可以把数组扁平化
真不知道,除了mdn上写tostring就是把所有object变成字符串
10.你简历上的一个网站怎么做移动端适配的?
对不起我没做这个。
11.用过react和vue吗?
没有,在谷歌实习用的polymer
12.google chrome怎么做测试的?
。。。一系列实习相关问题。。
最后被拒了,最迷的是被拒没有邮件,需要自己去系统查。
move on了。
. check 1point3acres for more.
.--
补充内容 (2019-6-16 23:09):
我都挂了可怜我打了这么多代码加个米吧!!谢谢谢谢 |
上一篇: 阿里巴巴 电面 一面面经下一篇: Airbnb 北京onsite
|