zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    ZOJ 3818 Pretty Poem
    HDU 4597 Play Game
    HDU 4497 GCD and LCM
    CSU 1335 高桥和低桥
    UVA 10791 Minimum Sum LCM
    CSU 1119 Collecting Coins
    CSU 1120 病毒
    UVA 12169 Disgruntled Judge
    HDU 1301 Jungle Roads
    POJ 1258 Agri-Net
  • 原文地址:https://www.cnblogs.com/linjiangxian/p/11950559.html
Copyright © 2011-2022 走看看