javascript - js方法调用问题

查看:78
本文介绍了javascript - js方法调用问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

T1调用anPoint1,为什么第二个参数用function(_e){},还_e这个参数是用来接收返回还是赋值的?

 var T1=function(e,t,src,target,top,left,width,background){
          
        anPoint1(e,function(_e) {

            o[t] = _e[0];
            if (t == "logoimg") {
                var _slk = function(_oa){
                    if(_oa==true){
                        _sta[t] = true;
                    }else{
                        var h = B(); //var B
                        o.logoheight=h.height;
                        o.logowidth=h.width;
                        o.logoleft=h.left;
                        o.logotop=h.top;
                    }
                };
                if(e!=null){
                    _slk();
                    N();//var N
                }else{
                    var _timeout = null;
                    _slk(true);
                }
            }else if(e!=null||background){
                u.drawImage()
            }else{
                _sta[t] = true;
            }
            imgReso[t] = 'url:'+src;
        },src,target,t,top,left,width,background);
    }  
########################################################################################

var anPoint1 = function(e, t,src,target,d,top,left,width,background) {
        if (e) {
            function r() {
                var s = new Image;
                s.src = src;
                if (target) {
                    target.attr('src',src)
                }
                n.push(s);//把logo的img对象传入n数组,作为logo参数 在画布中画出
                t(n);
            }
        }
        else{
            function r(){
                var s1=new Image;
                s1.src=src;
                if (target) {
                    target.attr('src',src)
                }
                s1.onload=function(){
                    n.push(s1);//把logo的img对象传入n数组,作为logo参数 在画布中画出
                    if (d=='background') {
                        var w=s1.width,
                            h=s1.height,
                            bl=h/w;
                        if (Math.max(w,h)<o.maxwidth) {
                            if (w>=h) {
                                o.bgwidth=w;
                                v=o.bgwidth;
                                o.max=o.maxwidth;
                            }
                            else{
                                o.bgwidth=h;
                                v=o.bgwidth;
                                o.max=o.maxwidth*bl;
                            }
                        }
                        else  {
                            if (w>=h) {
                                o.bgwidth=o.maxwidth;
                                v=o.bgwidth;
                                o.max=o.maxwidth
                            }
                            else{
                                o.max=o.maxwidth*bl;
                                o.bgwidth=o.maxwidth*bl;
                                v=o.bgwidth;
                            }
                        }
                        ewmcsh = true;
                            var ewmtop = o.ewmtop;
                            var ewmleft = o.ewmleft;
                            o.ewmleft = parseInt(left) * o.bgwidth / 270 || o.ewmleft;
                            o.ewmtop = parseInt(top) * o.bgwidth / 270 || o.ewmtop;
                            var ewmdjw = o.width;
                            o.width = parseInt(width) * o.bgwidth / 270 || o.width;
                            bl1 = (o.width-o.margin*2)/ o.bgwidth;
                            bl2 = (o.ewmtop+o.margin) / o.bgwidth;
                            bl3 = (o.ewmleft+o.margin) / o.bgwidth;
                            if (top != 0 && left != 0 && width != '') {
                                ewmcsh = false;
                                if (background) {
                                    o.bgColor = o.bgColor == 'rgba(225,225,225,0)' ? background : o.bgColor;
                                    $('#resetBgColor').css('display', 'block');
                                }
                                var logowbl = o.logowidth / ewmdjw;
                                var logohbl = o.logoheight / ewmdjw;
                                var logotopbl = (o.logotop  - ewmtop) / ewmdjw;
                                var logoleftbl = (o.logoleft  - ewmleft) / ewmdjw;
                                o.logowidth = o.width * logowbl;
                                o.logoheight = o.width * logohbl;
                                o.logotop = o.width * logotopbl + o.ewmtop;
                                o.logoleft = o.width * logoleftbl + o.ewmleft;
                                logozdz();
                            }
                            $('#qrcode_size').val(o.bgwidth);
                            $('#qrcode_size1').val(o.bgwidth);
                            //slidersize.setvalue(o.bgwidth);
                    }
                    t(n);
                }
            }
        }
        t = t || S;
        var n = [];
        r();
    };



解决方案

因为第二个参数的参数类型就是一个函数,参数类型不一定只有字符串 数字或者布尔类型的,把函数当参数传递你没用过么?_e是传递过去的这个函数自己的参数 你就把它当成一个函数去理解就ok了 就像是简单的
function(a){ alert(a) }; 这个_e跟a没什么区别

这篇关于javascript - js方法调用问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆