export const isDef = (input: unknown): boolean => typeof input !== 'undefined' // eslint-disable-next-line @typescript-eslint/no-empty-function export const NOOP = () => {} export const getVcStr = (str, maxlength) => { /// 获得字符串实际长度,中文2,英文1 /// 要获得长度的字符串 const len = str.length let realLength = 0, charCode = -1, realStr = str for (let i = 0; i < len; i++) { charCode = str.charCodeAt(i) if (charCode >= 0 && charCode <= 128) realLength += 1 else realLength += 2 if (realLength > maxlength) { realStr = realStr.substr(0, i) } } return realStr }