You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

13 lines
471 B

//判断是否为线上订单
export const startsWith = (mainStr, prefix) => {
// 处理前缀为空字符串的情况(空字符串是所有字符串的前缀)
if (prefix === '') {
return true;
}
// 处理主字符串长度小于前缀长度的情况
if (mainStr.length < prefix.length) {
return false;
}
// 比较主字符串开头与前缀相同长度的部分
return mainStr.substring(0, prefix.length) === prefix;
}