在調用Api請求數據服務端一直提示商品id只能是數字,經過仔細檢查才發現傳參爲id,但在請求地址裏面直接直接寫了id,沒有使用變量形式拼接,記錄下。。
把 const {data:res} =await this.$axios.get(`/goods/${id}`)
寫成了:const {data:res} =await this.$axios.get(`/goods/id`)
//點擊編輯時獲取商品id,再根據商品id查詢商品信息 async getGoodsDataById(id){ console.log(id,typeof id); const {data:res} =await this.$axios.get(`/goods/${id}`) if(res.meta.status !==200){ this.$message.error(`無法獲取到商品信息:${res.meta.msg}`) console.log(res); return } this.$message.success('已經獲取到商品數據') },