SOURCE

console.clear();
const SPEICALARR = ['add', 'edit', 'detail'];
const pathname = '/fresh-delivery/online-product/add/transfer'
const pathArr = pathname.split('/')
const speicalIndex = pathArr.findIndex((item) => SPEICALARR.includes(item));

console.info(pathArr,speicalIndex,pathArr[speicalIndex])


const index = pathname.lastIndexOf('add')

console.info(index,pathname.substring(1, index))
console 命令行工具 X clear

                    
>
console