problem description
the callback function of simditor uploading image successfully is to generate base64, unable to generate img tag and assign it in the form of src. I look up the source code to change the callback function successfully and did not execute
.the environmental background of the problems and what methods you have tried
simditor
related codes
/ / Please paste the code text below (do not replace the code with pictures)
this.editor.uploader.on("uploadsuccess", (function(_this) {
console.log("qwe")
return function(e, file, result) {
var $img, img_path, msg;
if (!file.inline) {
return;
}
$img = file.img;
if (!($img.hasClass("uploading") && $img.parent().length > 0)) {
return;
}
if (typeof result !== "object") {
try {
result = $.parseJSON(result);
} catch (_error) {
e = _error;
result = {
success: false
};
}
}
if (result.success === false) {
msg = result.msg || _this._t("uploadFailed");
alert(msg);
img_path = _this.defaultImage;
} else {
img_path = result.file_path;
}
_this.loadImage($img, img_path, function() {
var $mask;
$img.removeData("file");
$img.removeClass("uploading").removeClass("loading");
$mask = $img.data("mask");
if ($mask) {
$mask.remove();
}
$img.removeData("mask");
_this.editor.trigger("valuechanged");
if (_this.editor.body.find("img.uploading").length < 1) {
return _this.editor.uploader.trigger("uploadready", [file, result]);
}
});
if (_this.popover.active) {
_this.popover.srcEl.prop("disabled", false);
return _this.popover.srcEl.val(result.file_path);
}
};
})(this));
upload: {
url: "www.baidu.com", //
params: {
}, //,,
fileKey: "file", //
connectionCount: 3,
leaveConfirm: "",
},
toolbarFloat: true,
toolbarFloatOffset: 0,
toolbarHidden: false,
pasteImage: false,
cleanPaste: false,
textarea: $(this.refs.textarea)
};
this.editor = new Simditor(config);//
this.editor.setValue(this.props.value);
this.editor.uploader.on("uploadsuccess", (res,file,mask)=>{
//
console.log("1111")
let img = file.img;
console.log(res);
console.log(file);//simditor
console.log(mask);//mask
if(mask.code===200){
alert("");
img.attr("src","http://.jpg");//imgsrc
}else {
alert(",");
}
});
what result do you expect? What is the error message actually seen?