【发布时间】:2021-09-19 16:56:11
【问题描述】:
我想让我的值返回到外面,以便在我的 vue 端显示它,但我不明白..
我在状态文件中的 getter (vueX)
getTotalPrice: (state) => {
var totalPrice = axios.get("http://" + url + "/meals/")
.then((meals) => {
var price = 10
//ignore this for simplicity ---------------
state.all_orders.forEach((order) => {
price += order.quantity * meals.data.find(elem => elem.id === order.meal_id).price
})
//------------------------------------------
return price
})
return totalPrice
}
它应该返回 10 作为总价,我在控制台中得到它,但仍然在 vue 端得到 [object Promise]
感谢您的帮助!
【问题讨论】: