javascript - js function parameter passing problem
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:24:16
0
2
360
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梦

reply all(2)
漂亮男人

習慣沉默

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template