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

  })

}

相关文章

  • 模仿的音乐webapp

    基于 Vue(2.5) + vuex + vue-router + vue-axios +better-scrol...

  • 开发中的axios

    [axios npm地址]https://www.npmjs.com/package/vue-axios 安装日常...

  • Vue框架+axios使用详细教程

    1、安装 npm install --save axios vue-axios或 cnpm install --s...

  • vue使用axios

    先npm install axios再npm install --save axios vue-axios安装成功...

  • vuecliPC项目笔记

    vue-axios跨域使用 在config.index.js设置本地代理 proxyTable: { '/api'...

  • vue 网络请求封装笔记

    准备工作 1.引入axiosnpm install --save axios vue-axios引入qs npm ...

  • vue-Axios

    基于Promise 用于浏览器和 node.js的与服务器通讯的库支持Promise API安装 使用 npm: ...

  • vue-axios

    1.引进axios import axios from 'axios' 2.配置默认基准路径 axios.defa...

  • vue-axios

    引入部分 方法部分 html部分

  • vue-axios

    两种引用的方法 通过cdn或者下载下来去引用 或者通过npm使用看了这么多文章通过自己的尝试 1 npm i ax...

网友评论

      本文标题:vue-axios

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