me/Web前端面试题.md
2025-04-29 12:30:11 +08:00

24 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## v-if和v-show的区别分别适合什么场景
v-if 操作的实际上是 dom 元素的创建或销毁。v-show 操作的是display:none/block属性。频繁地切换使用 v-show否则使用 v-if。
## async await 关键字的用途
async await 是es7里面的新语法async 用于声明一个异步函数await 阻塞等待一个异步方法执行完成。
## Cookie 、LocalStorage 、 SessionStrorage的区别
- Cookie 是 http 协议的组成部分,会在同源 http 请求中携带数据根据不同浏览器限制大小一般不能超过4k
- LocalStorage 和 SessionStrorage 仅会持久化存储大小一般是5M
## this 的指向有哪些
1、普通函数中的 this 指向 window
2、定时器中的 this 指向 window
3、箭头函数没有 this它的 this 指向取决于外部环境
4、事件中的 this 指向事件的调用者 黑马程序员
5、构造函数中 this 和原型对象中的 this都是指向构造函数 new 出来实例对象
6、class 中的 this 指向由 constructor 构造器 new 出来的实例对象
7、自调用函数中的 this 指向 window