zoukankan      html  css  js  c++  java
  • axios

    axios基本使用

      axios({

        method: 'get',

        url: 'xxx',

        params: data,

        headers: {token: 'xxxxx'}

      }).then(res => {console.log(res)})

      axios({

        method: 'post',

        url: 'xxx',

        data: data,

        headers: {token: 'xxxx'}

      }).then(res => {console.log(res)}) 

      axios.get('xxx', {params: data}).then(res => {console.log(res)})

      axios.post('xxx', data).then(res => {console.log(res)})

    封装axios,request.js

      import  axios  from  'axios';

      axios.defaults.baseURL  =  'http://192.168.1.130:8020'

      // 请求拦截器

      axios.interceptors.request.use(function(confit){

        // 在发送请求前做相应的操作

        config.headers["token"] = ''

        return  config;

      }, function(error){

        //请求出错

        return  Promise.reject(error);

      })

      // 响应拦截器

      axios.interceptors.response.use(function(res){

        // 返回响应数据前做相应操作

        return  res;

      }, function(error){

        return  Promise.reject(error);

      })

      

      export  default  axios;

  • 相关阅读:
    菜单展开效果
    css3 实现运动动画 圆与椭圆
    css3 翻起页脚
    css3 实现loading效果
    css3
    jquery/原生js/css3 实现瀑布流以及下拉底部加载
    JSON
    js中变量声明提前
    Object.prototype.toString.call(obj)检测数据类型
    call,apply,bind与es6的数组扩展运算符...
  • 原文地址:https://www.cnblogs.com/cuishuangshuang/p/13473458.html
Copyright © 2011-2022 走看看