request.js
// 请求模块
import axios from 'axios'
const request = axios.create({
baseURL: 'url'
})
export default request
user.js
import request from '@/utils/request'
export const login = (data) => {
return request({
method: 'post',
url: `url`,
data
})
}
login.vue
import { login } from '@/api/user'
async onSubmit (values) {
try {
const res = await login()
console.log(res)
} catch (error) {
console.log(error)
}
}
网友评论