1.0.8 • Published 4 years ago

@jeebey/vue-request v1.0.8

Weekly downloads
7
License
ISC
Repository
-
Last release
4 years ago

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)
  })
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago