版本说明:
{
"name": "wx_vue_3.0",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.27.2",
"core-js": "^3.8.3",
"vant": "^3.6.4",
"vue": "^3.2.13",
"vue-router": "^4.0.3",
"vuex": "^4.0.0",
"weixin-js-sdk": "^1.6.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-router": "~5.0.0",
"@vue/cli-plugin-vuex": "~5.0.0",
"@vue/cli-service": "~5.0.0"
}
}
仅简单配置Axios后引入使用,返回“参数错误”。并不是参数错误,而是后端接收不到参数。仔细看文档
Axios中文文档
GET参数{params:{参数名:值}} 即{params:{paramName:paramValue}}
const getContent = () => {
let params = {
course_id:proxy.$route.params.course_id
}
let param = {
course_id:proxy.$route.params.course_id
}
//proxy.$milliaAxios.get(baseUrl, {params}).then(response => {
//proxy.$milliaAxios.get(baseUrl, {params:param}).then(response => {
proxy.$milliaAxios.get(baseUrl, {params: {course_id:proxy.$route.params.course_id}}).then(response => {
console.log(response.data)
})
}
//axois.get(地址,{params}).then(response=>{})
//注:params实际为params:{course_id:proxy.$route.params.course_id}
POST参数 {参数名:值}即{paramName:paramValue}
const goTag = () => {
let params = {
activeId:store.state.activityID
}
proxy.$milliaAxios.post(baseUrl,param).then(response => {
console.log(response.data)
}
//axois.post(地址,params).then(response=>{})
//注:params实际为{activeId:store.state.activityID}