手写源码
码农有梦想
每天进步一点点
展开
-
模仿ES6的promise手写一个自己的promise
class Mypromise { constructor(handle) { this.status = ‘pedding’;//状态 this.value = undefined;//结果 this.resolveFn = []; this.rejectFn = []; handle(this._resolve.bind(this), this._reject.bind(this)) } _resolve(val) { this.status = ‘fulfilled’; this.value = va原创 2021-05-06 17:18:40 · 115 阅读 · 0 评论 -
模仿vue手写一个mvvm框架
//wather和依赖收集器 不依赖key值生成对应的dep //利用ES6的Proxy来 get收集依赖;set发布 class MyVue{ constructor(options){ this.options=options;this.options=options; this.options=options;this.data=options.data; this.observe(this.KaTeX parse error: Expected 'EOF', got '}' a原创 2021-05-06 17:16:01 · 138 阅读 · 0 评论