如何绕过beforerouteleave nuxtjs组件

发布于 2025-02-07 21:57:20 字数 388 浏览 2 评论 0原文

我使用beforerouteleave用于打开的对话框组件使用router调用组件时。

beforeRouteLeave(to, from, next) {
  if (to.name === "read-content") {
    this.displayProductModal(to);
  } else {
    next();
  }
},

当我将nux-link调用read-content(route.name)页面时,对话框打开。有时我不想运行对话框。但是我想直接访问该页面,该怎么办?

I use beforeRouteLeave for open dialog component when calling component with router.

beforeRouteLeave(to, from, next) {
  if (to.name === "read-content") {
    this.displayProductModal(to);
  } else {
    next();
  }
},

When I call nuxt-link to the read-content (route.name) page a dialog opens. Sometimes I don't want to run the dialog. But I want to access that page directly, what should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赏烟花じ飞满天 2025-02-14 21:57:20

我找到了答案,我在参数中使用条件 - > if(to.hash) route> outder/# url
如果还有其他更好的方法,请建议我。

:to="{
  name: 'read-content',
  params: { content: id },
  hash: '#x',
}"

I found my answer, i use condition in parameter to -> if(to.hash) add token or fake param after route/# url.
If there is any other better way please suggest me.

:to="{
  name: 'read-content',
  params: { content: id },
  hash: '#x',
}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文