vue-router-best-practices
改进 Vue Router 导航守卫
Vue Router 问题可能导致数据陈旧、重定向失效以及路由检查薄弱。此技能为守卫、参数、清理和生产环境路由提供聚焦模式。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "vue-router-best-practices" from https://skillstore.io/skills/vuejs-ai-vue-router-best-practices.md and its manifest at https://skillstore.io/api/skills/vuejs-ai-vue-router-best-practices/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“vue-router-best-practices”。 用户详情页在从一个用户路由切换到另一个用户路由后显示上一个用户。
预期结果:
响应会将组件复用识别为原因。它建议监听 route id 或使用 onBeforeRouteUpdate 来获取新数据。
正在使用“vue-router-best-practices”。 auth guard 将每次未认证导航都重定向到登录路由。
预期结果:
响应会解释重定向循环风险。它建议排除公开路由,或在返回登录重定向前使用 route meta。
正在使用“vue-router-best-practices”。 一个团队想替换生产 Vue 应用中的简单 hash router。
预期结果:
响应会比较简单路由与 Vue Router 功能。它会强调懒加载、route meta、history mode 和 navigation guards。
安全审计
安全All 15 static findings were false positives after context review. The dynamic imports are static Vue Router lazy-loading examples, the backticks are JavaScript log template literals, and the route checks are tutorial code. No evidence found of prompt injection, data exfiltration, filesystem access, command execution, or malicious intent.
风险因素
⚡ 包含脚本 (6)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/vuejs-ai-vue-router-best-practices/audits/5?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/vuejs-ai-vue-router-best-practices?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/vuejs-ai-vue-router-best-practices?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/vuejs-ai-vue-router-best-practices/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/vuejs-ai-vue-router-best-practices.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
github.com/vuejs-ai. (2026). vue-router-best-practices security audit report (audit version 5) [Author version 1.0.0]. Skillstore. https://skillstore.io/skills/vuejs-ai-vue-router-best-practices/audits/5BibTeX 引用
@techreport{github-com-vuejs-ai-vuejs-ai-vue-router-best-practices-2026,
author = {github.com/vuejs-ai},
title = {vue-router-best-practices security audit report (audit version 5)},
institution = {Skillstore},
year = {2026},
number = {5},
url = {https://skillstore.io/skills/vuejs-ai-vue-router-best-practices/audits/5},
note = {Author version 1.0.0}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "vue-router-best-practices security audit report (audit version 5)"
version: "1.0.0"
type: report
authors:
- name: "github.com/vuejs-ai"
date-released: "2026-07-07"
url: "https://skillstore.io/skills/vuejs-ai-vue-router-best-practices/audits/5"
identifiers:
- type: other
value: "skillstore:vuejs-ai-vue-router-best-practices:audit:5"
description: "Skillstore immutable audit report identifier"
比较变体
2 个可安装变体每位作者的技能都保持为独立的可安装项。推荐变体按 Skillstore 证据排序。
为什么此变体排名第一
antfu-vue-router-best-practices
2026-09-09
vuejs-ai-vue-router-best-practices
2026-09-09
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
修复守卫错误
诊断 Vue Router 导航守卫中的重定向、缺失的 await 以及已弃用的 next 调用。
审查路由驱动的数据
检查路由参数变化是否通过 watchers 或组件内更新守卫重新加载数据。
规划生产环境路由
为懒加载、route meta、history mode 和清理职责选择 Vue Router 模式。
试试这些提示
使用 vue-router-best-practices skill 解释为什么我的 Vue Router 导航行为不正确。重点关注 guards、params 和 lifecycle timing。
使用 vue-router-best-practices skill 审查我的 auth guard。用基于 return 的 Vue Router 4 模式替换已弃用的 next 用法。
使用 vue-router-best-practices skill 设计一种安全模式,用于在复用组件中的 route params 变化时加载数据。
使用 vue-router-best-practices skill 审计我的 SPA 路由架构,检查 redirect loops、async guard failures、cleanup gaps 和 production readiness。
最佳实践
- 使用基于 return 的 Vue Router 4 守卫来处理重定向、取消和正常导航。
- 使用 watchers 或 onBeforeRouteUpdate 处理同一路由的参数变化。
- 生产环境 SPA 应使用 Vue Router,而不是手写 hash 路由。
避免
- 依赖 beforeEnter 来验证同一路由内的参数变化。
- 多次调用 next,或在旧版守卫中忘记调用它。
- 添加 hashchange 监听器却未在组件清理期间移除。
常见问题
此技能面向哪个 Vue Router 版本?
它能为我的应用编写路由代码吗?
只有路由参数变化时,beforeEnter 会运行吗?
我还应该在导航守卫中使用 next 吗?
此技能是否涵盖重定向循环预防?
此技能可以安全发布吗?
开发者详情
许可证
MIT
作者版本
v1.0.0
Skillstore 修订
r1
引用
36e07d5e13068e5be64447e8f20b427cf2cbd21a
维护新鲜度
2026/7/18
使用量
13 次下载 · 152 次浏览
文件结构
📄 router-beforeenter-no-param-trigger.md
📄 router-beforerouteenter-no-this.md
📄 router-guard-async-await-pattern.md
📄 router-navigation-guard-infinite-loop.md
📄 router-navigation-guard-next-deprecated.md
📄 router-param-change-no-lifecycle.md
📄 router-simple-routing-cleanup.md
📄 router-use-vue-router-for-production.md
📄 SKILL.md