axios使用

 

1.安装axios

npm install axios --save

2.main.js 引用 

import axios from 'axios'

3.配置接口

axios.defaults.baseURL="http://localhost:9999";

4.export default中加入请求

methods: {
get () {
this.$http({ method: 'get', url: '/test/test' }).then(
(resp) => {
resp.data
}, (error) => {
console.log('error=' + JSON.stringify(error))
}).catch((exception) => {
})
}
},
posted @ 2020-12-05 09:11  想学前端的小李  阅读(33)  评论(0)    收藏  举报