$(document).on('pjax:complete', function() { const url = location.href if (url.indexOf('/user/login') > -1) { // 匹配路由 执行相应代码 initStarsPage() } })