/** * this util module is about to verify, fix strings like phone, QR code and so on * @module angle-util/textUtil */ export default { /** * 修正电话号码格式 * @author youngbeen * @param {number|string} phone - 待修正的手机号 * @return {string} 修正后的号码 * @example * let phone = '12345ab384eb(2' * textUtil.fixPhoneStr(phone) // '123453842' */ fixPhoneStr (phone: number | string): string { if (phone || phone === 0) { // change phone into string type at first phone = phone.toString() // remove all invalid characters in phone phone = phone.replace(/[^0-9,]/g, '') return phone } else { return '' } } }