我試圖從函數獲取count
值,並且想要存儲在函數的外部。sails:如何獲得函數外的值
var count;
client.count({
index: 'employee',
type: 'details',
}, function (err, response) {
if(err){console.log(err)}
count = response.count
console.log(count);
});
console.log(count); 我想在該功能之外使用此計數。 這可能嗎?
你從找出一個複製粘貼了。這會起作用,但不推薦。理想情況下,您應該使用回調函數返回所有值。 – galactocalypse
我已經搜索過關於這個問題,但可以找到。 – Martin
沒有它不適合我。 – Martin