成功? '发送':'失败'默认为'发送'成功=空。 为什么?

我正在使用nodeJS(使用nodemailer lib)发送电子邮件,目前我在整个邮件处理过程中遇到了一些超时问题。 这不是我需要帮助的问题。 这个问题我需要帮助的是,当它到达日志logging部分时,成功将为空,并且sole.log('Message'+使整个console.log语句输出“sent”。没有“Message”,没有失败。

任何想法为什么?

nodemailer.send_mail( // e-mail options { to:"alexsb92@gmail.com", sender:"alexsb92@gmail.com", subject:"node_mailer test email", html:'<p><b>Hi,</b> how are you doing?</p>', body:'Hi, how are you doing?' }, // callback function function(error, success){ console.log('Message ' + success ? 'sent' : 'failed'); } ); 

运算符优先级? 尝试:

 'Message ' + (success ? 'sent' : 'failed') 

这是您的业务重点。 +运算符比三元运算符具有更高的优先级,因此您实际上正在执行

 console.log(('Message ' + success) ? 'sent' : 'failed'); 

这总是如此。 相反,做:

 console.log('Message ' + (success ? 'sent' : 'failed'));