1.0.8 • Published 5 years ago
@jeebey/vue-request v1.0.8
vue-request
介绍
基于axios的网络请求封装 不支持SSR
安装
npm i @jeebey/vue-request使用说明
import Vue from 'vue'
import xhttp from '@jeebey/vue-request'
Vue.use(xhttp, {
  cross: true,
  domain: '',
  prefix: '',
  // 请求参数
  requests: function(cfg) {
    
  },
   // 响应结果
  responses: function(res){
    
  }
})接口文档
get(url,data,head)
post(url,data,head)
body(url,data,head)
form(url,data,head)
download(url,data,head)
使用示例
  this.$http.get('sample/get',{}).then(data=>{
       console.log(data)
  })
  this.$http.post('sample/post',{},{head:''}).then(data=>{
       console.log(data)
  })
  this.$http.body('sample/body',{}).then(data=>{
       console.log(data)
  })  
  this.$http.form('sample/form',{}).then(data=>{
       console.log(data)
  })  缓存请求
  this.$http.cache().get('sample/get',{}).then(data=>{
       console.log(data)
  })
  this.$http.cache(true, 5000).post('sample/post',{},{head:''}).then(data=>{
       console.log(data)
  })终止请求
  this.$http.abort().get('sample/get',{}).then(data=>{
       console.log(data)
  })
  this.$http.abort(true, true).post('sample/post',{},{head:''}).then(data=>{
       console.log(data)
  })