vue中axios传参
程序员文章站
2024-03-17 18:37:04
...
安装
npm install axios --save 安装
main.js配置
文件中使用
methods: {
findStudentGradeList () {
this.$axios.post('/api/student/findStudentGradeList', this.studentGrade,
{headers: {'content-Type': 'application/json;charset=utf-8'}})
.then(successResponse => {
console.log(successResponse)
this.tableData = successResponse.data
})
.catch(failResponse => {
alert('系统繁忙')
})
}
}
需要在config的index.js中配置
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
//我配置的地方
proxyTable: {
'/api': {
target: 'http://localhost:8082',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
上一篇: 初探MySQL之索引INDEX
推荐阅读