我有这个 :
if (this.router.url === '/test/sort') { this.active = 0; }
问题是,有时url将是test / sort?procesId = 11并且不会输入if语句.任何建议我怎么能这样做?
解决方法
有更好/更清洁的解决方案,但如果你想要一些基本的工作:
if (this.router.url.indexOf('/test/sort') > -1) { this.active = 0; }