我无法从nodejs的mysql连接检查功能获取返回数据。输出始终为假。
var dbcheck = false;
connection.connect(function (err) {
if(err) {
dialog.showMessageBox(null,dbOptions, function (response) {
if(response == 1){
shell.openExternal("https://innoscript.co");
app.quit();
}
if(response == 0){ app.quit(); }
});
}
if(!err){
dbcheck = true;
return dbcheck;
}
});
console.log(dbcheck);
答案 0 :(得分:0)
您的console.log()在连接建立之前执行。
您应该在回调函数中使用console.log()。