文末
篇幅有限没有列举更多的前端面试题,小编把整理的前端大厂面试题PDF分享出来,一共有269页
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
Vue结构
1、Vue constructor 构造函数主要是数据的初始化
2、proxyData 数据代理
3、observer 劫持监听所有数据
4、compile 解析dom
5、compileText 解析dom里处理纯双花括号的操作
6、Watcher 更新视图操作
Vue constructor 初始化
上面主要是初始化操作,针对传过来的数据进行处理
proxyData 代理data
上面主要是代理data到最上层,this.xxx的方式直接访问data
observer 劫持监听
同样是使用Object.defineProperty来监听数据,初始化需要订阅的数据。
把需要订阅的数据到push到watcherTask里,等到时候需要更新的时候就可以批量更新数据了。👇下面就是;
遍历订阅池,批量更新视图。
compile 解析dom
lass Vue{
constructor(options = {}){
…
}
proxyData(key){
…
}
observer(data){
…
}
compile(el){
var nodes = el.childNodes;
for (let i = 0; i < nodes.length; i++) {
const node = nodes[i];
if(node.nodeType === 3){
var text = node.textContent.trim();
if (!text) continue;
this.compileText(node,‘textContent’)
}else if(node.nodeType === 1){
if(node.childNodes.length > 0){
this.compile(node)
}
if(node.hasAttribute(‘v-model’) && (node.tagName === ‘INPUT’ || node.tagName === ‘TEXTAREA’)){
node.addEventListener(‘input’,(()=>{
let attrVal = node.getAttribute(‘v-model’)
this.watcherTask[attrVal].push(new Watcher(node,this,attrVal,‘value’))
node.removeAttribute(‘v-model’)
return () => {
this.data[attrVal] = node.value
}
})())
}
if(node.hasAttribute(‘v-html’)){
let attrVal = node.getAttribute(‘v-html’);
this.watcherTask[attrVal].push(new Watcher(node,this,attrVal,‘innerHTML’))
node.removeAttribute(‘v-html’)
}
this.compileText(node,‘innerHTML’)
if(node.hasAttribute(‘@click’)){
let attrVal = node.getAttribute(‘@click’)
node.removeAttribute(‘@click’)
node.addEventListener(‘click’,e => {
this.methods[attrVal] && this.methods[attrVal].bind(this)()
})
}
}
}
},
compileText(node,type){
let reg = /{{(.*)}}/g, txt = node.textContent;
if(reg.test(txt)){
node.textContent = txt.replace(reg,(matched,value)=>{
let tpl = this.watcherTask[value] || []
tpl.push(new Watcher(node,this,value,type))
return value.split(‘.’).reduce((val, key) => {
算法
-
冒泡排序
-
选择排序
-
快速排序
-
二叉树查找: 最大值、最小值、固定值
-
二叉树遍历
-
二叉树的最大深度
-
给予链表中的任一节点,把它删除掉
-
链表倒叙
-
如何判断一个单链表有环
由于篇幅限制小编,pdf文档的详解资料太全面,细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!
如果你觉得对你有帮助,可以戳这里获取:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
叙
-
如何判断一个单链表有环
[外链图片转存中…(img-7HskRAfV-1715009761956)]
由于篇幅限制小编,pdf文档的详解资料太全面,细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!