vue-axios

作者: vzii | 来源:发表于2018-09-18 17:33 被阅读0次

    1.引进axios

    import axios from 'axios'

    2.配置默认基准路径

    axios.defaults.baseURL = 'http://127.0.0.1:3000'

    1.get请求(没参数)

    export const RootLogin = () => {

      return axios.get('/employee/checkRootLogin').then((res) => {

        return res

      })

    }

    2.get请求(两个参数,以对象的形式)

    export const User = (pa) => {

      return axios.get('/user/queryUser', {params: pa}).then((res) => {

        return res

      })

    }

    3.post请求(两个参数,登录接口)

    export const Login = (logoForm) => {

      return axios.post('employee/employeeLogin', logoForm).then((res) => {

        return res

      })

    }

    4.post请求(一个参数)

    export const addCategory = (pa) => {

      return axios.post('/category/addTopCategory', {categoryName: pa}).then((res) => {

        return res

      })

    }

    相关文章

      网友评论

          本文标题:vue-axios

          本文链接:https://www.haomeiwen.com/subject/xhwynftx.html