微秀

微秀

126飞吻 2017-2-2 加入 来自阳江

(哈哈,我很懒的)

微秀 最近的提问

微秀 最近的回答

  • 7天前upload模块怎么退步了??中回答:

    最新版的这样携带token可以,
    	            upload.render({
    elem: '#orderadd',
    accept: 'file',
    exts: 'csv',
    size: 1024*4, //限制文件大小,单位 KB
    url: 'http://up.qiniu.com/',
    data: {token: '{$token}',key:"234324.csv"},
    auto: true,
    multiple: false,
    done: function(res) {

    }
    });
    不过我还是觉得uptoken_url这个好使,全网能使用一个接口,不用每个上传模块都写上token
  • 7天前upload模块怎么退步了??中回答:

    怪了,我好像没改过啊~~~反正今天使用 uptoken_url,不好使,以前用下面这个代码好使,建议也加上这个参数啊,能异步读取token,

    /** layui-v2.1.5 MIT License By http://www.layui.com */
    ;layui.define("layer",function(e){"use strict";var i=layui.$,t=layui.layer,n=layui.hint(),a=layui.device(),o={config:{},set:function(e){var t=this;return t.config=i.extend({},t.config,e),t},on:function(e,i){return layui.onevent.call(this,r,e,i)}},l=function(){var e=this;return{upload:function(i){e.upload.call(e,i)},config:e.config}},r="upload",u="layui-upload-file",c="layui-upload-form",s="layui-upload-iframe",f="layui-upload-choose",p=function(e){var t=this;t.config=i.extend({},t.config,o.config,e),t.render()};p.prototype.config={accept:"images",exts:"",auto:!0,bindAction:"",url:"",uptoken_url:"",field:"file",method:"post",data:{},drag:!0,size:0,multiple:!1},p.prototype.render=function(e){var t=this,e=t.config;e.elem=i(e.elem),e.bindAction=i(e.bindAction),t.file(),t.events()},p.prototype.file=function(){var e=this,t=e.config,n=e.elemFile=i(['<input class="'+u+'" type="file" name="'+t.field+'"',t.multiple?" multiple":"",">"].join("")),o=t.elem.next();(o.hasClass(u)||o.hasClass(c))&&o.remove(),a.ie&&a.ie<10&&t.elem.wrap('<div class="layui-upload-wrap"></div>'),e.isFile()?(e.elemFile=t.elem,t.field=t.elem[0].name):t.elem.after(n),a.ie&&a.ie<10&&e.initIE()},p.prototype.initIE=function(){var e=this,t=e.config,n=i('<iframe id="'+s+'" class="'+s+'" name="'+s+'" frameborder="0"></iframe>'),a=i(['<form target="'+s+'" class="'+c+'" method="'+t.method,'" key="set-mine" enctype="multipart/form-data" action="'+t.url+'">',"</form>"].join(""));i("#"+s)[0]||i("body").append(n),t.elem.next().hasClass(s)||(e.elemFile.wrap(a),t.elem.next("."+s).append(function(){var e=[];return layui.each(t.data,function(i,t){e.push('<input type="hidden" name="'+i+'" value="'+t+'">')}),e.join("")}()))},p.prototype.msg=function(e){return t.msg(e,{icon:2,shift:6})},p.prototype.isFile=function(){var e=this.config.elem[0];if(e)return"input"===e.tagName.toLocaleLowerCase()&&"file"===e.type},p.prototype.preview=function(e){var i=this;window.FileReader&&layui.each(i.chooseFiles,function(i,t){var n=new FileReader;n.readAsDataURL(t),n.onload=function(){e&&e(i,t,this.result)}})},p.prototype.upload=function(e,t){var n,o=this,l=o.config,r=o.elemFile[0],u=function(){if(o.chooseFiles&&l.uptoken_url){i.getJSON(l.uptoken_url,function(res){layui.each(e||o.files||o.chooseFiles||r.files,function(e,t){var n=new FormData;n.append("token",res.uptoken),n.append(l.field,t),layui.each(l.data,function(e,i){n.append(e,i)}),i.ajax({url:l.url,type:l.method,data:n,contentType:!1,processData:!1,dataType:"json",success:function(i){d(e,i)},error:function(){o.msg("请求上传接口出现异常"),m(e)}})})});}else{layui.each(e||o.files||o.chooseFiles||r.files,function(e,t){var n=new FormData;n.append(l.field,t),layui.each(l.data,function(e,i){n.append(e,i)}),i.ajax({url:l.url,type:l.method,data:n,contentType:!1,processData:!1,dataType:"json",success:function(i){d(e,i)},error:function(){o.msg("请求上传接口出现异常"),m(e)}})})}},c=function(){var e=i("#"+s);o.elemFile.parent().submit(),clearInterval(p.timer),p.timer=setInterval(function(){var i,t=e.contents().find("body");try{i=t.text()}catch(n){o.msg("获取上传后的响应信息出现异常"),clearInterval(p.timer),m()}i&&(clearInterval(p.timer),t.html(""),d(0,i))},30)},d=function(e,i){if(o.elemFile.next("."+f).remove(),r.value="","object"!=typeof i)try{i=JSON.parse(i)}catch(t){return i={},o.msg("请对上传接口返回有效JSON")}"function"==typeof l.done&&l.done(i,e||0,function(e){o.upload(e)})},m=function(e){l.auto&&(r.value=""),"function"==typeof l.error&&l.error(e||0,function(e){o.upload(e)})},v=l.exts,h=function(){var i=[];return layui.each(e||o.chooseFiles,function(e,t){i.push(t.name)}),i}(),g={preview:function(e){o.preview(e)},upload:function(e,i){var t={};t[e]=i,o.upload(t)},pushFile:function(){return o.files=o.files||{},layui.each(o.chooseFiles,function(e,i){o.files[e]=i}),o.files}},y=function(){return"choose"===t?l.choose&&l.choose(g):(l.before&&l.before(g),a.ie?a.ie>9?u():c():void u())};switch(h=0===h.length?r.value.match(/[^\/\\]+\..+/g)||[]||"":h,l.accept){case"file":if(v&&!RegExp("\\w\\.("+v+")$","i").test(escape(h)))return o.msg("选择的文件中包含不支持的格式"),r.value="";break;case"video":if(!RegExp("\\w\\.("+(v||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(h)))return o.msg("选择的视频中包含不支持的格式"),r.value="";break;case"audio":if(!RegExp("\\w\\.("+(v||"mp3|wav|mid")+")$","i").test(escape(h)))return o.msg("选择的音频中包含不支持的格式"),r.value="";break;default:if(layui.each(h,function(e,i){RegExp("\\w\\.("+(v||"jpg|png|gif|bmp|jpeg$")+")","i").test(escape(i))||(n=!0)}),n)return o.msg("选择的图片中包含不支持的格式"),r.value=""}if(l.size>0&&!(a.ie&&a.ie<10)){var F;if(layui.each(o.chooseFiles,function(e,i){if(i.size>1024*l.size){var t=l.size/1024;t=t>=1?Math.floor(t)+(t%1>0?t.toFixed(1):0)+"MB":l.size+"KB",r.value="",F=t}}),F)return o.msg("文件不能超过"+F)}y()},p.prototype.events=function(){var e=this,t=e.config,o=function(i){e.chooseFiles={},layui.each(i,function(i,t){var n=(new Date).getTime();e.chooseFiles[n+"-"+i]=t})},l=function(i,n){var a=e.elemFile,o=i.length>1?i.length+"个文件":(i[0]||{}).name||a[0].value.match(/[^\/\\]+\..+/g)||[]||"";a.next().hasClass(f)&&a.next().remove(),e.upload(null,"choose"),e.isFile()||t.choose||a.after('<span class="layui-inline '+f+'">'+o+"</span>")};t.elem.off("upload.start").on("upload.start",function(){var a=i(this),o=a.attr("lay-data");if(o)try{o=new Function("return "+o)(),e.config=i.extend({},t,o)}catch(l){n.error("Upload element property lay-data configuration item has a syntax error: "+o)}e.config.item=a,e.elemFile[0].click()}),a.ie&&a.ie<10||t.elem.off("upload.over").on("upload.over",function(){var e=i(this);e.attr("lay-over","")}).off("upload.leave").on("upload.leave",function(){var e=i(this);e.removeAttr("lay-over")}).off("upload.drop").on("upload.drop",function(n,a){var r=i(this),u=a.originalEvent.dataTransfer.files||[];r.removeAttr("lay-over"),o(u),t.auto?e.upload(u):l(u)}),e.elemFile.off("upload.change").on("upload.change",function(){var i=this.files||[];o(i),t.auto?e.upload():l(i)}),t.bindAction.off("upload.action").on("upload.action",function(){e.upload()}),t.elem.data("haveEvents")||(e.elemFile.on("change",function(){i(this).trigger("upload.change")}),t.elem.on("click",function(){e.isFile()||i(this).trigger("upload.start")}),t.drag&&t.elem.on("dragover",function(e){e.preventDefault(),i(this).trigger("upload.over")}).on("dragleave",function(e){i(this).trigger("upload.leave")}).on("drop",function(e){e.preventDefault(),i(this).trigger("upload.drop",e)}),t.bindAction.on("click",function(){i(this).trigger("upload.action")}),t.elem.data("haveEvents",!0))},o.render=function(e){var i=new p(e);return l.call(i)},e(r,o)});
  • 7天前upload模块怎么退步了??中回答:



    	            upload.render({
    elem: '#addBtn',
    accept: 'file',
    exts: 'jpg|jpge|gif|png',
    size: 1024*2, //限制文件大小,单位 KB
    url: 'http://up.qiniu.com/',
    uptoken_url: "/aimeike/uptoken.html",
    auto: true,
    multiple: false,
    done: function(res) {
    parent.layer.closeAll('loading');
    parent.layer.msg('图片上传中...', {
    time: 1500
    }, function() {
    $newkey = parent.PREFIX_FILE_HOST + res.key;
    $image.cropper('replace', $newkey);
    parent.addpic2album($newkey);
    $.post("/aimeike/qiniuupload.html", {
    "key": res.key,
    "name": "aimeike",
    "action":"upfile"
    });
    });
    }
    });
  • 2018-11-5 21:43:40求个正则的写法中回答:

    $aaa="{a:1, b:2, c:3}";

    echo preg_replace("/(\w+)\s*:/","\"$1\":",$aaa);
  • 2018-11-5 21:31:32求个正则的写法中回答:

    @IDyun ,感谢~~
  • 2018-11-4 17:4:58求个正则的写法中回答:

    @IDyun

    需要PHP的~~~
  • 2018-11-4 9:10:8想去掉layer.open的loading中回答:

    @Zlheb 我被加载页面有loading,所以不去掉的话,前后会显示两个不同样式的loading,很难看
  • 2018-10-27 9:3:0想去掉layer.open的loading中回答:

    找到办法了,方法很土,
    找到那个loading的图片,然后css里搜索,找到相关的dom “layui-layer-load”
    最后写了个皮肤 demo-class

    body .demo-class .layui-layer-title{background:#c00; color:#fff; border: none;}
    body .demo-class .layui-layer-btn{border-top:1px solid #E9E7E7}
    body .demo-class .layui-layer-btn a{background:#333;}
    body .demo-class .layui-layer-btn .layui-layer-btn1{background:#999;}
    body .demo-class .layui-layer-load{background:#48424e}
  • 2018-10-27 8:35:46想去掉layer.open的loading中回答:

    @Zlheb
    我也想过修改,但是这个东西闪一闪就消失了,找不到相关的DOM,无处下牙啊
  • 2018-10-26 17:20:14外部如何引用layui里面的方法??中回答:

    @IDyun
    测试失败,有成功案例看一下?
  • 2018-10-1 22:11:35layer无论是手机版或者pc版,在苹果手机上,或者开发者模式手机模式下,都无法弹出中回答:

    @mfei
    主要是没错误信息啊~~
  • 2018-9-29 20:1:16layer无论是手机版或者pc版,在苹果手机上,或者开发者模式手机模式下,都无法弹出中回答:

    不知道怎么检查哪里出了问题
  • 2018-4-15 21:13:54layuiAdmin 和 LayIM 授权特惠活动中回答:

    贵!贵!贵!贵!贵!
  • 2017-12-31 19:3:18遍历dom的灵活用法?中回答:

    function Selector(cssSelector) {
    var all = document.querySelectorAll(cssSelector);
    var arr = [];
    for (var i = 0; i < all.length; i++) {
    if (all[i].querySelectorAll('*').length == 0) {
    arr.push(all[i])
    }
    }
    return arr;
    }
  • 2017-12-31 19:1:57遍历dom的灵活用法?中回答:



    这个办法更灵活~~