在router的index.js文件夹里面配置
1. router.beforeEach((to, from, next) => { 2. console.log(to, from); 3. // 判断是否为复制的地址栏中的链接 4. const isCopiedLink = !from.name && to.path !== '/' 5. 6. if (isCopiedLink) { 7. // 如果是复制的链接,则重定向到首页 8. next({ path: '/' }) 9. } else { 10. next() 11. } 12. })