想用mongoose獲取db中數據的總量,并把這個總量賦給其他變量function count(cb){ database.model('mesModel',mesSchema).find().count(function(err,num){ cb(num) }}function key(x){ return console(x)}count(key)//正常顯示數字var a = count(key)//undefined如果給一個全局變量var a function key(x){ return a = x}console.log(a)//undefined要怎樣把count里面的num賦予外面的變量呢?
請教一個關于回調函數取值的問題
慕的地8271018
2019-02-02 19:15:26