Commit f02c7f20 authored by 何虹's avatar 何虹 💬

编译成es5

parent 8a18c7ac
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,7 +2,7 @@
"name": "hswebhttpclient",
"version": "1.0.3",
"description": "dync中httpClient基础插件",
"main": "./src/index.js",
"main": "./dist/hsWebHttpClient.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
......
import axios from 'axios'
class Root {
filterEmptyValue(obj) {
filterEmptyValue (obj) {
if (!obj) return
const emptyValues = [null, undefined, 'null', 'undefined', NaN]
for (const k in obj) {
......@@ -12,25 +12,28 @@ class Root {
}
}
}
get(url, params, headers, config) {
get (url, params, headers, config) {
return this.request('get', url, null, params, headers, config)
}
post(url, data, params, headers, config) {
post (url, data, params, headers, config) {
return this.request('post', url, data, params, headers, config)
}
put(url, data, params, headers, config) {
put (url, data, params, headers, config) {
return this.request('put', url, data, params, headers, config)
}
delete(url, data, params, headers, config) {
delete (url, data, params, headers, config) {
return this.request('delete', url, data, params, headers, config)
}
requestConfig(config) {
requestConfig (config) {
return axios(config)
}
request(method, url, data, params, headers = null, config = {}) {
request (method, url, data, params, headers = null, config = {}) {
this.filterEmptyValue(data)
// 公共头设置
const aixosCtx = { method, url, ...config }
const aixosCtx = { method, url,...config }
// if (config) {
// Object.assign(aixosCtx, config)
// }
params && (aixosCtx.params = params)
if (aixosCtx.params && aixosCtx.params.token) delete aixosCtx.params.token
if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info
......
......@@ -2,6 +2,7 @@ const TerserPlugin = require('terser-webpack-plugin') // 引入压缩插件
module.exports = {
mode: 'none', // 因为默认是production 默认会进行压缩
target: ['web', 'es5'],//← ← ←就是这个
entry: {
"hsWebHttpClient": "./src/index.js",
"hsWebHttpClient.min": "./src/index.js"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment