js文件
export const getLogin = ( code,avatarUrl,nickName ) => request({url: '/api/login/login',method: 'post',data: {code,avatarUrl,nickName }})
code,avatarUrl,nickName 这些是传的参
引入 :vue里面的js
const res = await getLogin(this.code,this.avatarUrl,this.nickName)
可以将这些参数换成一个对象
export const getLogin = ( obj) => request({url: '/api/login/login',method: 'post',data: obj})
后面request里面data的大括号也不需要了
引入 : vue里面的js
let info = {
code:this.code,
avatarUrl:this.avatarUrl,
nickName:this.nickName
}
const res = await getLogin(info)
效果是一样的