字符串转成正则表达式
方案:使用new RegExp 或 eval,要注意特殊字符转义 和 贪婪匹配
// menu.path /gatewa/*
// 正则贪婪匹配const reg =menu.path && new RegExp(`^${menu.path.replace(/\//g, '\\/').replace(/\*/g, '[\\d\\w-]*')}$`);
字符串转成正则表达式
方案:使用new RegExp 或 eval,要注意特殊字符转义 和 贪婪匹配
// menu.path /gatewa/*
// 正则贪婪匹配const reg =menu.path && new RegExp(`^${menu.path.replace(/\//g, '\\/').replace(/\*/g, '[\\d\\w-]*')}$`);