my project is to select the resource bit first, and then there are multiple resource bits selected under different stores (such as industry store orientation, store orientation, etc.). The resource bit under each store is the same, and then the average market reference price is requested according to the id of the store and the id of the resource bit, as shown in figure
.
I tried to use computed processing, and then passed parameters with closure, but found that computed could not use axios to request the average price I asked for. Later, I found an asyncComputed, written by Daniel, which solved the problem that I wanted computed to be used with axios, but there was a problem that return would not return to the page after I requested the interface.
HTML Code:
{{computedAverage(2097152,val.adzone_id)}}</span>
Js:
asyncComputed: {
computedAverage:{//
get () {
return function(itemId,resourceId) {//
this.$axios.get("/zuanzhan/price/suggest", {
params: {
target_type: itemId,
adzone_id: resourceId
}
}).then((res)=>{
console.log(res.data.data.price)//
return res.data.data.price// "{}"
})
}
},
}
},
I would like to ask if you have ever encountered a similar situation. You can use computed to pass parameters and use axios to request, or if you have any other good ideas, please teach me. Thank you