main.js 中:

import axios from 'axios'

Vue.protoytpe.$http = axios

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

购买详情页中:

getPrice () {

let buyVersionsArray = _.map(this.versions, (item) => {

return item.value

})

let reqParams = {

buyNumber: this.buyNum,

buyType: this.buyType.value,

versions: this.period.value,

period: buyVersionsArray.join(',')

}

this.$http.post('/api/getPrice', reqParams)

.then((res) => {

this.price = res.data.data.amount

})

.catch((err) => {

console.log(err)

})

}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

控制台报错信息:

POST http://localhost:8080/api/getPrice 404 (Not Found)

Error: Request failed with status code 404

at createError (createError.js?16d0:16)

at settle (settle.js?db52:18)

at XMLHttpRequest.handleLoad (xhr.js?ec6c:77)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

请问这是为什么呢?使用get请求是没问题的。

从网上搜了一搜,有的说重新实例化axios,有的说需要引用qs对发送的数据处理一下,我都试了还是报404

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐