上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页
摘要: Vue 的 $nextTick 是实现异步更新的核心 API,其实现方式经历了演变: 1. 实现原理 $nextTick 的本质是将回调函数延迟到下一个 DOM 更新周期之后执行。 2. 实现方式演变 2.1 优先使用微任务 (Microtask) // Vue 2.5+ 的实现 const cal 阅读全文
posted @ 2025-10-13 16:27 阿木隆1237 阅读(11) 评论(0) 推荐(0)
摘要: Vue2 的初始化过程主要包括以下几个核心步骤: 1. 初始化流程概述 // Vue 构造函数 function Vue(options) { this._init(options) } 2. 初始化阶段 2.1 _init() 方法 Vue.prototype._init = function(o 阅读全文
posted @ 2025-10-13 15:33 阿木隆1237 阅读(20) 评论(0) 推荐(0)
摘要: // 防抖函数 function debounce(func, wait, immediate = false) { let timeout; return function executedFunction(...args) { const context = this; const later 阅读全文
posted @ 2025-10-13 00:49 阿木隆1237 阅读(8) 评论(0) 推荐(0)
摘要: 待添加 阅读全文
posted @ 2025-10-13 00:47 阿木隆1237 阅读(3) 评论(0) 推荐(0)
摘要: var name = 'window'​​ const person1 = { ​ name: 'person1',​ foo1: function() {​ console.log(this.name) ​ }, ​ foo2: () => { console.log(this.name) ​ } 阅读全文
posted @ 2025-10-13 00:30 阿木隆1237 阅读(4) 评论(0) 推荐(0)
摘要: bind、apply、call 的区别及内在实现 核心区别 方法 调用方式 参数传递 立即执行 返回值 call 直接调用 参数列表 是 函数执行结果 apply 直接调用 参数数组 是 函数执行结果 bind 返回新函数 参数列表 否 绑定this的新函数 详细解析 1. call 方法 func 阅读全文
posted @ 2025-10-11 17:27 阿木隆1237 阅读(22) 评论(0) 推荐(0)
摘要: function myNew(constructor, ...args) { ​ const obj = Object.create(constructor.prototype); // 创建一个新对象并链接到构造函数的原型​ const result = constructor.apply(obj 阅读全文
posted @ 2025-10-11 17:01 阿木隆1237 阅读(4) 评论(0) 推荐(0)
摘要: function MyPromise(executor) {​ // 初始化Promise的状态和结果 ​ this._state = 'pending'; ​ this._value = undefined;​​ // 回调函数数组,用于存储成功和失败回调 ​ this._callbacks = 阅读全文
posted @ 2025-10-11 16:58 阿木隆1237 阅读(6) 评论(0) 推荐(0)
摘要: function Animal(name) { ​ this.name = name; ​} ​​Animal.prototype.speak = function() { ​ console.log(this.name + ' makes a sound');​ };​​ function Dog 阅读全文
posted @ 2025-10-11 16:44 阿木隆1237 阅读(5) 评论(0) 推荐(0)
摘要: 在 JavaScript 中,内存泄漏通常发生在不需要的内存没有被垃圾回收器释放时。以下是常见的几种情况: 1. 意外的全局变量 // 意外的全局变量 function foo() { bar = "这是一个全局变量"; // 没有使用 var/let/const } function baz() 阅读全文
posted @ 2025-10-11 14:53 阿木隆1237 阅读(14) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页