vuex返回有效负载数据中的未定义。无法访问它以从api更新数据 handleSubmit(){ 此.$store.dispatch(“updateProduct”{ 名称:this.form.name, 价格:“$”+this.form.price, 品
vuex返回有效负载数据中的未定义。无法访问它以从api更新数据vuex返回有效负载数据中的未定义。无法访问它以从api更新数据 handleSubmit(){ 此.$store.dispatch(“updateProduct”{ 名称:this.form.name, 价格:“$”+this.form.price, 品,api,axios,vuex,store,put,Api,Axios,Vuex,Store,Put,vuex返回有效负载数据中的未定义。无法访问它以从api更新数据 handleSubmit(){ 此.$store.dispatch(“updateProduct”{ 名称:this.form.name, 价格:“$”+this.form.price, 品牌:这个, inventoryStatus:this.form.inventoryStatus==“true”, }) updateProduct:async({commit},有效负载)=>{ 试一试{ console.log(payloa
handleSubmit(){
此.$store.dispatch(“updateProduct”{
名称:this.form.name,
价格:“$”+this.form.price,
品牌:这个,
inventoryStatus:this.form.inventoryStatus==“true”,
})
updateProduct:async({commit},有效负载)=>{
试一试{
console.log(payload.id)
让结果=等待axios.put(`http://localhost:3000/products/${payload.id}`,payload);
提交('UPDATE_PRODUCT',result.data)
}捕获(错误){
抛出新错误('api更新错误:',错误)
}
}
PUT/products/undefined 404 5.234 ms-2您没有在payload
中传递id
。您传递的是name
、price
、brand
和inventory status
。您希望id
来自哪里?好的,让我试试。。。