param v param defaultNumber param radix export function parseNumber ( v , defaultNumber = 0 , radix = 10 ) { if ( v === undefined ) { v = defaultNumber ; } else { v = parseInt ( v , radix ) ; if ( Number . isNaN ( v ) ) { v = defaultNumber ; } } return v ; } param len param radix export function uuid ( len , radix = 16 ) { const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' . split ( '' ) ; const res = [ ] ; let i ; radix = radix || chars . length ; if ( len ) { for ( i = 0 ; i < len ; i ++ ) res [ i ] = chars [ 0 | ( Math . random ( ) * radix ) ] ; } else { let r ; res [ 8 ] = res [ 13 ] = res [ 18 ] = res [ 23 ] = '-' ; res [ 14 ] = '4' ; for ( i = 0 ; i < 36 ; i ++ ) { if ( ! res [ i ] ) { r = 0 | ( Math . random ( ) * 16 ) ; res [ i ] = chars [ i === 19 ? ( r & 0x3 ) | 0x8 : r ] ; } } } return res . join ( '' ) ; } param len export function getRandomString ( len ) { len = len || 4 ; const $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghijklmnopqrstuvwxyz0123456789' ; const maxPos = $chars . length ; let s = '' ; for ( let i = 0 ; i < len ; i ++ ) { s += $chars . charAt ( Math . floor ( Math . random ( ) * maxPos ) ) ; } return s ; } param str export function kebabCasedToCamel ( str ) { return str . split ( '-' ) . map ( x => x . length > 0 && x [ 0 ] . toUpperCase ( ) ) . join ( '' ) ; } param str returns export function camelToKebabCased ( str ) { return str . replace ( /([A-Z])/g , '-$1' . toLowerCase ( ) ) . replace ( /^-/ , '' ) ; } /**
 * 查找一个数组是否存在该元素，如果不存在，则将其添加
 */ export function addIfNotExist < T > ( arr , item ) { if ( arr . indexOf ( item ) === - 1 ) { arr . push ( item ) ; } return arr ; } /**
 * 将一个具有样式格式的字符串按照对象格式添加到对象中
 */ export function addStyleStrToObject ( obj , styleStr ) { styleStr . split ( ';' ) . forEach ( item => { const [ key , value ] = item . split ( ':' ) ; if ( key && value ) { obj [ key . trim ( ) ] = value . trim ( ) ; } } ) ; }