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) => {
})
}
},