0.3.7 • Published 4 years ago

@deepjs/uni-axios v0.3.7

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

uni-axios

自定义适配器,支持在 uni-app 中使用 axios

依赖 axios,兼容性好,并提供最佳实践

使用

// main.js
import axios from '@deepjs/uni-axios'

Vue.prototype.$axios = axios
// api/user.js文件
const api = require("./api.js");
import Vue from 'vue';

// 获取登陆验证码
export const userRegister = (params) => {
  return Vue.prototype.$axios.post(
    api.userRegister,
    params,
  )
}
// page.vue
const apiUser = require('@/api/user')
//.........
apiUser.userRegister(params).then(res => {
    console.log("获取登陆验证码成功啦:",res)
  }).catch(err => {
    console.log("获取验证码失败啦:",err)
  })