/dialogs/attachment/attachment.js文件1.将 _this.fileList.push(json); 修改为 _this.fileList[$file.index()] = json;2.修改getInsertList 方法为:getInsertList: function () { var i, link, data, list = [], prefix = editor.getOpt('fileUrlPrefix'); for (i = 0; i < this.fileList.length; i++) { data = this.fileList[i]; if(data === undefined){ continue; } link = data.url; list.push({ title: data.original || link.substr(link.lastIndexOf(

const a = document.createElement('a')const url = body.data['fileUrl']a.href = urla.click()window.URL.revokeObjectURL(url)

for in 与Object.keys()的区别function test(a, b) { this.a = a; this.b = b; } test.prototype = { c: "c" } var _a = new test("a", 1); console.log(Object.keys(_a));//["a","b"] for (var key in _a) { console.log(key); // a,b,c }总结:Object.keys():返回一个数组,数组值为对象自有的属性,不会包括继承原型的属性for in :遍历对象可枚举属性,包括自身属性,以及继承自原型的属性

前言在面试的时候,经常会有面试官让你实现一个 Promise,如果参照 A+规范来实现的话,可能面到天黑都结束不了。 说到 Promise,我们首先想到的最核心的功能就是异步链式调用,本篇文章就带你用 20 行代码实现一个可以异步链式调用的 Promise。 这个 Promise 的实现不考虑任何异常情况,只考虑代码最简短,从而便于读者理解核心的异步链式调用原理。代码function Promise(fn) { this.cbs = []; const resolve = (value) => { setTimeout(() => { this.data = value; this.cbs.forEach((cb) => cb(value)); }); } fn(resolve); } Promise.prototype.then = function (onResolved) { return new Promise((resolve) => { this.cbs.push(() =