1.2.6 • Published 4 years ago
@ninggure/utils v1.2.6
axiosRequest
axios请求封装
- GET
import {get} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const params = {
a: 1
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
get(url, params, headers, responseType)- POST
import {post} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const data = {
a: 1
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
post(url, params, headers, responseType)- 上传文件(POST)
import {uploadFile} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const data = {
file
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
uploadFile(url, params, headers, responseType)deepClone
深拷贝对象或数组
- depthDeepClone(深度遍历深拷贝)
import {depthDeepClone} from "@ninggure/utils/deepClone";
const a = {test: 1, test2: 2, test3: {
test: 1
}}
// 深拷贝一个a对象
const newA = depthDeepClone(a);
console.log(a === newA) // false- breadthDeepClone(广度遍历深拷贝)
import {breadthDeepClone} from "@ninggure/utils/deepClone";
const a = {test: 1, test2: 2, test3: {
test: 1
}}
// 深拷贝一个a对象
const newA = breadthDeepClone(a);
console.log(a === newA) // falsefileList
遍历目录里面的所有内容
- getDepthFileList(深度遍历)
const {getDepthFileList} = require("@ninggure/utils/fileList");
const dirPath = "xxxx";
getDepthFileList(dirPath)- getBreadthFileList(广度遍历)
const {getBreadthFileList} = require("@ninggure/utils/fileList");
const dirPath = "xxxx";
getBreadthFileList(dirPath)1.2.6
4 years ago
1.2.5
4 years ago
1.2.4
4 years ago
1.2.3
5 years ago
1.2.2
5 years ago
1.2.1
5 years ago
1.2.0
5 years ago
1.1.9
5 years ago
1.1.8
5 years ago
1.1.7
5 years ago
1.1.6
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.1.2
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.3
5 years ago
1.0.0
5 years ago