Commit 3a334936 by member

增加uitls功能函数

parent f151f755
//公共方法
/**
*测试
* params name 姓名
*/
export const test = function(name) {
return name;
* 从数组中移除指定元素
* @param { arr } 源数组
* @param { item } 要移除的元素
*/
export function remove(arr, item) {
if (arr.length) {
const index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1);
}
}
}
/**
* 检查obj是否具有属性值key
*/
const hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasOwn(obj) {
return hasOwnProperty.call(obj, key);
}
/**
* 连字符转驼峰
*/
const camelizeRE = /-(\w)/g;
export function camelize(str) {
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '');
}
/**
* 首字母大写
*/
export function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
/**
* toArray 将类数组对象转为数组
*/
export function toArray(list, start) {
start = start || 0;
let i = list.length - start;
const ret = new Array(i);
while(i--) {
ret[i] = list[i + start];
}
}
\ No newline at end of file
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