var web = {
aa:function(){
var _this = this;
function ss() {
console.log()
}
ss()
}
}
web.aa("blue")
怎么在ss函数里面获取web.aa的参数啊   也就是"blue"

解决方案 »

  1.   


    aa:function() {
    var args = arguments;
    var _this = this;
    function ss() {
    args//就是你传给web.aa的参数,如果调用web.aa("blue")的话args[0]就是"blue"
    console.log()
    }
    ss()
    }
      

  2.   

    我想用apply或call来获取..要怎么来写啊 ?
      

  3.   

    一样的,你在ss函数的定义中引用了传给aa的参数,随便你怎么调用都能获取
      

  4.   

    写给我看看apply的写法啊 ?
      

  5.   

    帮我看看下面的代码:
    var web = {
    set:function(){
    var _this = this;
    return function(){
    console.log(_this.aa.arguments)
    }()
    },
    aa:function(){
    var _this = this;
    _this.set()
    $(arguments[0]).onclick = function(){
    _this.set()
    }
    }
    }
    web.aa("test")
    点击后这句代码是null..为什么会这样?
    $(arguments[0]).onclick = function(){
    _this.set()
    }
      

  6.   

    $(arguments[0]).onclick
    首先jquery不是应该这样吗:$(arguments[0]).click
    另外调用web.aa("test")时arguments[0]是"test";在你的页面中$("test")如果找不到对象的话就是null
      

  7.   

    我用的是原生写的.
    $("test") 是可以找得到的.
    你在onclick里面加个alert试试就知道了
      

  8.   

    如果你只是单纯的检验有没有获取到aa的参数,用的着搞这么复杂吗
    下面的代码你看看有没有输出参数var web = {
                    aa:function(){
                        var args = arguments;
    function ss() {
    console.log(args[0]);
    }
    ss();
                    }
                }
                web.aa("test123");
      

  9.   


    // 2 继承,上下文,call和apply的用法
    var Person = function(xm){
    this.xm = xm;
    this.say = function(){
    console.log("my name'is "+ this.xm);
    }
    }var a = {};
    Person.call(a,'hhp');
    a.say();var Employee = function(com){
    this.com = com;
    this.tell = function(){
    console.log("I'm woking in "+ this.com);
    }
    }Employee.apply(a,['botian']);
    a.tell();