1.0.3 • Published 5 years ago

@tydic-group/plugin-service v1.0.3

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

plugin-service

封装请求

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

For detailed explanation on how things work, consult the docs for vue-loader.

使用方式

1.引用插件

import ServiceRequest from '@tydic-group/plugin-service'

2.设置处理请求地址

ServiceRequest.setting({})

  • 默认的以localhost发送请求; 在设置的对象里有三个参数可以传递
        1. baseUrl: 设置发送请求需要的公共路径, 例如: /zdpyc/door/, 默认为空
        2. env: 设置当前环境, 默认为'development'
        3. declareURL: 类型为方法, return出一个完整的请求的地址
    3.设置请求拦截操作 ServiceRequest.settingRes({})
  • 在设置的对象里有五个参数可以传递

      1. redirectAct: 类型为方法; 接口302重定向操作
      2. notLogin: 类型为方法; 未登录操作
      3. closeLoading: 类型为方法; 关闭加载框
      4. showLoading: 类型为方法; 开启加载框
      5. alert: 类型为方法; 提示