-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue面试题 #6
Comments
组件通信方式Vue:
React:
|
Vue3 和 Vue2 的区别1.API 方面:
2.性能方面:
3.维护性:
|
说一下 Composition API函数式的优势
还有就是函数式的优势
Composition API
与 React Hooks 对比
|
vue 响应式理解
function reactive(target) {
const handler = {
get(target, key, receiver) {
const res = Reflect.get(target, key, receiver);
track(target, key); // 收集依赖
if (isObject(res)) return reactive(res); // 如果是对象,递归懒代理
return res;
},
set(target, key, value, receiver) {
const oldValue = target[key]; // 获取老的值
const result = Reflect.set(target, key, value, receiver);
if (!Object.is(oldValue, value)) {
trigger(target, key);
}
return result;
},
};
return new Proxy(target, handler);
}
// track: 收集依赖 存放targetMap: `WeakMap<object, Map<key, Set<effect>>`
|
虚拟 DOM 和 Diff虚拟 DOM:
diff 算法:
key 的作用 key 的作用是为了更高效的更新 DOM,diff 算法的目标就是尽可能复用原来对应的节点,减少 dom 操作量。 key 就是 vnode 的唯一 id,在 dom diff 的过程中,通过 key 找到对应原型的节点,来减少 dom 操作量,提升视图更新的性能。
|
模板编译原理Vue2 的过程是 parse -> optimize -> generate optimize:优化原始 AST,标记静态节点。 Vue3 更加标准化,中间过程为 transform
vue3 的编译优化:编译阶段尽可能提取关键信息
|
双向绑定
|
nextTick
|
slot 实现原理
|
keep-alive
|
路由实现原理一个 SPA 应用的路由需要解决的问题是页面跳转内容改变同时不刷新
|
pinia 对比 vuex
|
The text was updated successfully, but these errors were encountered: