• wangEditor——图片上传失败提示


    wangEditor 官网自定义上传事件:https://www.kancloud.cn/wangfupeng/wangeditor2/123689

    声明:我用的wangEditor版本是2.1.23

    js:

    var editor = new wangEditor('div1');
    // 普通的自定义菜单
    editor.config.menus = [
              ···
    ]; // 上传图片 editor.config.uploadImgUrl = '***'; editor.config.uploadImgFileName = '***'; // 自定义load事件 editor.config.uploadImgFns.onload = function (resultText, xhr) { //不知道是不是因为后台没有返回error,我的图片上传只进入onload方法,我用的谷歌浏览器 // resultText 服务器端返回的text // xhr 是 xmlHttpRequest 对象,IE8、9中不支持 // 上传图片时,已经将图片的名字存在 editor.uploadImgOriginalName var originalName = editor1.uploadImgOriginalName || '';  if(resultText == '0'){ //这个判断取决于后端返回怎样的数据,针对个人情况修改 alert('图片上传失败'); } // 如果 resultText 是图片的url地址,可以这样插入图片: editor.command(null, 'insertHtml', '<img src="' + resultText + '" alt="' + originalName + '" style="max-100%;"/>'); //editor插入HTML
     //如果是vue懒加载的话需要加上data-src属性,否则会加载失败   
    //editor.command(null, 'insertHtml', '<img data-src="'+ resultText + '" src="' + resultText + '" alt="' + originalName + '" style="max-100%;"/>'); //editor插入HTML

    }; editor.create();
  • 相关阅读:
    html常用属性手记
    html常用标签手记
    linux安装与命令大全
    14.ref参数
    13.out参数
    10.结构
    9.枚举
    8.常量
    6.使用Convert进行类型转换
    5.C#中的转义符和@符号
  • 原文地址:https://www.cnblogs.com/linjiangxian/p/11950559.html
Copyright © 2020-2023  润新知