search

Home  >  Q&A  >  body text

javascript - js function parameter passing problem

function authorizationToWX(callback){
    console.log('1' + JSON.stringify(callback))
}
authorizationToWX({
    success: function(data){
        window.localStorage && window.localStorage.setItem('wxalreadylogin', JSON.stringify(data));
        setTimeout(function(){
            alert(123)
            me.investSuccessMoneyInfoApp();
        },3000)
    },
    error: function() {
        window.localStorage && window.localStorage.setItem('wxalreadylogin',     JSON.stringify(data));
        setTimeout(function(){
            alert(12)
            me.investSuccessMoneyInfoApp();
        },3000)
    }
})

The result obtained is 1{}, why is the function missing? ?

过去多啦不再A梦过去多啦不再A梦2840 days ago392

reply all(2)I'll reply

  • 漂亮男人

    漂亮男人2017-05-19 10:26:16

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-19 10:26:16

    The first floor has explained the specific situation, 6666

    Your callback is not json, so it cannot be consoled.
    What I want to say is:

     window.localStorage && window.localStorage.setItem('wxalreadylogin',JSON.stringify(data));
    

    Why isn’t this behavior made into a db method? It’s always ?? && dosomething. Isn’t it annoying? And if ?? is false, it is not processed at all, then what do you want?? && dosomething is actually Just to report one less error. The point is that IE8 and above already support localstorage.

    reply
    0
  • Cancelreply