我认为这是最容易用一个例子来解释的。
var my_variable = 10;
let my_sql = "select count(id) as id_count from table";
con.query(my_sql, function (err, my_result) {
if (my_result[0].id_count > 10) {
my_variable += 10;
}问题是:
con.query回调函数无法看到my_variable的值。
发布于 2018-07-08 01:25:21
问题出在我身上。过了很长时间,在我的代码中,my_variable被销毁了。但是因为查询耗时太长,所以在使用它之前就被销毁了……
https://stackoverflow.com/questions/51225274
复制相似问题