用数组的解构分别获取路由中的某一个字段

138 阅读1分钟
const path = '/foo/bar/baz'
const [ , first,center,last] = path.split('/')
console.log(first,center,last)    // foo  bar  baz