var mysql = require(' mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
port : '3306',
password : 'root',
database : 'test'
});
connection.connect(函数(ERR){
if(!err) {
console.log("database is connected"+database);
} else {
console.log("database is not connected"+err.message);
}
});
答案 0 :(得分:0)
将连接功能更改为如下所示:(用胖箭头功能替换功能" =>")
connection.connect((err) => {
if (!err) {
console.log("database is connected"+database);
} else {
console.log("database is not connected"+err.message);
}
});
以下链接解释了原因:
What is the difference between () => {} and function() {} in react-native javascript?