foxbenjaminfox/vue-async-computed

pass parameters

yangyanju opened this issue · 2 comments

When I pass the parameter, the final retrun value is empty.
The code is as follows:
html:
市场平均价格{{computedAverage(2048,val.adzone_id)}}元
js:
asyncComputed: {
computedAverage:{
get () {
return function(itemId,resourceId) {
this.$http.get('/zuanzhan/price/suggest', {
params: {
target_type: itemId,
adzone_id: resourceId
}
}).then((res)=>{
console.log(res.data.data.price)//24.5
return res.data.data.price//empty?
})
}
},
}
},

Why do u need passing params in computed ? Use methods instead.

Yes.Thank you!I've settled it.