@sincerecloud/sc-utils

sc-utils is a tools source
1,190
Install
npm install @sincerecloud/sc-utils
Latest Version:0.0.29
Vue:3
License:MIT
Last Updated:Mar 13, 2024
Links: Repository  ·  npm
Maintainer: peter---sss

@sincerecloud/sc-utils

  • 包含HighAxios 类,对axios 二次封装,处理预定状态码
  • 常用object处理方法
  • 中英翻译查询方法
  • 常用正则表达式

安装

npm install axios
npm install @sincerecloud/sc-utils

具体文档请使用 yarn dev 查看

初始化

初始化baseHttp工厂函数

import { HighAxios, getAxios } from '@sincerecloud/sc-utils'

// getAxios 初始化 工厂函数
const baseHttp = getAxios(config)
// or 通过HigAxios 初始化 工厂函数
// const getAxios = HighAxios(config)
// const baseHttp = getAxios(config)

object

查找方法

/**
 * @param {Object} obj 对象
 * @param {String} prototype 属性名
 * @returns Boolean
 */
export const hasOwn = (obj: Object, prototype: string) => {
  return Object.hasOwnProperty.call(obj, prototype);
};

/**
 * 深度获取对象的值
 * @param collection Data source
 * @param keyPath Key path array
 * @param notSetValue Default value for not found
 */
export const getObjectIn = (collection: Object, keyPath: string[], notSetValue:unknown = null) => {
  return keyPath.reduce((rlt: any, keyIndex: string) => {
    return (rlt && rlt[keyIndex] ? rlt[keyIndex] : null)
  }, collection) || notSetValue
}

Related Packages

vue-axios-cors

This is http client vue.js plugin for cross origin access without preflight. It...

14,521 5
iot-axios2

kaifangpingtai-vue2

1,597
@epoundor/vue-fetch

The ultimate solution for making API calls in your Vue.js projects

1,592 7
vue-axios

A small wrapper for integrating axios to Vuejs

5,218,200 1,996
vue-axios-plugin

axios plugin for Vuejs project

3,206 58

Version History

Version Released Vue License
0.0.29 ^3.2.47 MIT
0.0.28 ^3.2.47 MIT
0.0.27 ^3.2.47 MIT
0.0.26 ^3.2.47 MIT
0.0.25 ^3.2.47 MIT