当前位置:网站首页>面试第一家公司的面试题及答案(一)
面试第一家公司的面试题及答案(一)
2022-07-26 10:15:00 【Xaivor】
1.谈谈对跨域的理解,怎么处理跨域?
简单的理解:浏览器或者JavaScript说处于安全方面的考虑,对同源策略的限制。
处理的方法一:porxy代理
通过同域名的web服务器创建一个代理,比如说杭州的服务器后台(www.hangzhou.com/porxy-hangzhouservice.php)来调用广州服务器(www.guangzhou.com/server.php)的服务,然后再把响应的结果返回给前端,这样一来,前端调用杭州同域名的服务就和调用上海的服务效果相同了。处理的方法二:JSONP(不支持POST请求)
用于解决主流浏览器的跨数据访问的问题。
a.com中
<script>
function jsonp(json){
alert(json["name"]);
}
</script>
<script src="http://a.com/json.js"></script>
b.com中
jsonp({
'name':'小明', 'age':24});
- 处理的方法三:XHR2
H5提供的XMLHttpRequestLevel2已经实现了跨域访问以及其他的一些新功能。
IE10以下的版本都不支持
在服务器端做一些小小的改造即可
header(‘Access-Control-Allow-Origin:*’);
header(‘Access-Control-Allow-Methods:POST, GET’);
2.闭包的概念是什么?
- 闭包是定义在函数内部的函数
- 闭包是能访问包含函数的变量(能够读取其他函数内部变量的函数)
- 即使包含函数执行完了,被闭包引用的变量也得不到释放
三个条件:
- 访问所在作用域
- 函数嵌套
- 在所在作用域外被调用
IIFE(立即执行函数):满足1,不满足2和3。IIFE(立即执行函数):满足1,不满足2和3。
3.vue中的关于生命函数的概念
什么是vue生命周期?
答: Vue 实例从创建到销毁的过程,就是生命周期。也就是从开始创建、初始化数据、编译模板、挂载Dom→渲染、更新→渲染、卸载等一系列过程,我们称这是 Vue 的生命周期。vue生命周期的作用是什么?
答:它的生命周期中有多个事件钩子,让我们在控制整个Vue实例的过程时更容易形成好的逻辑。vue生命周期总共有几个阶段?
答:它可以总共分为8个阶段:创建前/后, 载入前/后,更新前/后,销毁前/销毁后第一次页面加载会触发哪几个钩子?
答:第一次页面加载时会触发 beforeCreate, created, beforeMount, mounted 这几个钩子DOM 渲染在 哪个周期中就已经完成?
答:DOM 渲染在 mounted 中就已经完成了。简单描述每个周期具体适合哪些场景?
答:生命周期钩子的一些使用方法: beforecreate : 可以在这加个loading事件,在加载实例时触发 created : 初始化完成时的事件写在这里,如在这结束loading事件,异步请求也适宜在这里调用 mounted : 挂载元素,获取到DOM节点 updated : 如果对数据统一处理,在这里写上相应函数 beforeDestroy : 可以做一个确认停止事件的确认框 nextTick : 更新数据后立即操作dom
4.绘制三角形的css样式
分析一波,三角形有很多种,但都离不开宽高为0,确定一条边为有颜色的,再使其它边颜色为透明transparent,代码如下:
#triangle{
/**这就是一个倒三角**/
width:0;
height:0,;
border-top:100px solid red; /**正三角脚改为bottom**/
border-right:50px solid transparent; /**如果要直角只需要一条边颜色,一条边为透明**/
border-left:50px solid transparent;
}
5.页面加载的过程
1.输入地址
2.浏览器查找域名的 IP 地址
3.这一步包括 DNS 具体的查找过程,包括:浏览器缓存->系统缓存->路由器缓存…
4.浏览器向 web 服务器发送一个 HTTP 请求
5.服务器的永久重定向响应(从 http://a.com 到 http://www.a.com)
6.浏览器跟踪重定向地址
7.服务器处理请求
8.服务器返回一个 HTTP 响应
9.浏览器显示 HTML
10.浏览器发送请求获取嵌入在 HTML 中的资源(如图片、音频、视频、CSS、JS等等)
11.浏览器发送异步请求
边栏推荐
- Learning about opencv (1)
- Learning about tensorflow (I)
- Set view dynamic picture
- Some descriptions of DS V2 push down in spark
- Docker configuring MySQL Cluster
- 数通基础-TCPIP参考模型
- Okaleido生态核心权益OKA,尽在聚变Mining模式
- SQL Server 2008 server engine failed to start?
- Rowselection emptying in a-table
- Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
猜你喜欢
Wechat applet learning notes 1
Learning about opencv (3)
Sqoop【环境搭建 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
服务发现原理分析与源码解读
2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
Distributed network communication framework: how to publish local services into RPC services
[MySQL database] a collection of basic MySQL operations - the basis of seeing (adding, deleting, modifying, and querying)
数通基础-STP原理
【有奖提问】向图灵奖得主、贝叶斯网络之父 Judea Pearl 提问啦
Like, "new programmer" e-book is free for a limited time!
随机推荐
Cloud native (36) | introduction and installation of harbor in kubernetes
Study notes of the fifth week of sophomore year
Rowselection emptying in a-table
Uniapp "no mobile phone or simulator detected, please try again later" and uniapp custom components and communication
Some descriptions of DS V2 push down in spark
[fluorescent character effect]
Draw arrows with openlayer
Principle analysis and source code interpretation of service discovery
On the compilation of student management system of C language course (simple version)
服务器内存故障预测居然可以这样做!
Time series anomaly detection
In the same CONDA environment, install pytroch first and then tensorflow
AirTest
Common errors when starting projects in uniapp ---appid
数通基础-网络基础知识
Azkaban [basic knowledge 01] core concepts + features +web interface + Architecture +job type (you can get started with Azkaban workflow scheduling system in one article)
Phpexcel export Emoji symbol error
Wechat applet development
The fourth week of summer vacation
Solution of inputting whole line string after inputting integer