文章 评论 浏览 26
class mockLocalStorage { constructor() { this.store = {} } getItem(key) { return this.store[key] || null } setItem(key,value) { this.store[key] = value } removeItem(key) { delete this.store[key] } clear() { this.store = {} } } window.localStorage2 = new mockLocalStorage()
文章 0 评论 0
接受
第 103 题:模拟实现一个 localStorage