我有一个功能
function gotData(data){
result = data.val()
const urls = Object.keys(result)
.filter(key => result[key].last_res > 5)
.map(key => ({url: 's/price/' + result[key].url_site + '/'}))
}
console.log(urls)
但我不能将console.log(urls)显示为错误
ReferenceError: urls is not defined
如何退回网址?
答案 0 :(得分:0)
你的函数gotData应该返回urls,
function gotData(data){
result = data.val()
return urls = Object.keys(result)
.filter(key => result[key].last_res > 5)
.map(key => ({url: 's/price/' + result[key].url_site + '/'}))
}
console.log(gotData(yourdata));