更新记录

1.1.0(2019-12-10)

android5.1以下导致白屏(console.log 使用了%c css样式的造成的

1.0.12(2019-11-16)

//

1.0.1(2019-08-24)

增加了上传接口

查看更多

平台兼容性

Request easy use


初始化实例 (api.js)

import request from './request'
import {Interceptor, Responder,errorHandler} from './custom'

const isDebug = process.env.NODE_ENV === "development"

let baseUrl = 'http://api.abadboy.cn/index/'
// #ifdef H5
    baseUrl = '/abadboy/' //跨域配置的指定代理前缀
// #endif

// 声明实例
let http = new request({baseUrl,isDebug,header:{test:"hello","Content-Type": "application/json"}})
http.customInterceptor=Interceptor//自定义拦截器
http.customResponder=Responder//自定义响应器
http.errorHandler=errorHandler

// API列表 对外暴露的接口
const api = {
    jssdk(data={}){
        return http.get('index/jssdk',{data,header={},contentType:'responseType'})
        // return http.post('index/jssdk',{data})
        // return http.put('index/jssdk',{data})
        // return http.option('index/jssdk',{data})
        // return http.delete('index/jssdk',{data})
    },
    upload(data){
        //仅单文件上传 data={filePath,name}

        // formData文件流上传
        return http.uploadFileStream('index/upload',{...data})
        //pryload方式
        return http.uploadPayload('index/upload',{...data})
        // formdata方式
        return http.uploadFormData('index/upload',{...data})
    }
}
export default api

main.js

import api from './js_sdk/resuest-easy-use/api'
Vue.prototype.api=api

使用

this.api.jssdk({url:"baidu.com"}).then(res=>{
                if(res){
                    console.log('「index.vue」这里是测试接口,页面逻辑处理部分',res)
                }
            })

将api维护为一个列表暴露出来是我自己习惯 , main.js中直接引用request也是可以的

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问