Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

继续求助JS二、三元运算转换正常代码的问题

return $(a).text().indexOf('已') > -1 ? (js.wx.confirm('要解除绑定吗?',
function(a) {
    "yes" == a && bd.weixin()
}), void 0) : js.iswx() ? (js.wx.load('处理中...')), js.location('?a=login&state=bang'), void 0) : (js.wx.alert('请在微信上打开'), void 0)

下面是转换后的,但是void 0 和上面的return该怎么处理??

if($(a).text().indexOf('已') > -1){
    js.wx.confirm('要解除绑定吗?',function(a){
        if(a == 'yes')bd.weixin();
    }), void 0);
}else{
    if(js.iswx()){
        js.wx.load('处理中...');
        js.location('?a=login&state=bang'), void 0
    }else{
        js.wx.alert('请在微信上打开'), void 0
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

void 0视作 undefined,无视;
由于 return 最终返回的是 void 0,而 undefined 又是函数的默认返回值,所以也无视。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...