Nuxtjs如何跳转到父页面

how to go to the parent page in Nuxtjs

假设我的 Nuxt.js 中有这个 url:

http://localhost:3000/sectionOne/someId/player

我想转到 someId 页面:

http://localhost:3000/sectionOne/someId

我写了这段代码,但它只是刷新了页面。我该如何解决?

      let hasan = Object.assign({}, this.$route);
      let hosein = delete hasan.params.player;
      this.$router.go({ hosein });

使用replace,go用于返回页面。要推动新路径,请使用 replacepush.

首先我们要做的是获取当前路径并将文本 '/player' 替换为 empty space.然后我们可以使用任意两个示例来完成我们的工作。

这是您的代码示例 replace:

let newUrl = this.$route.path.replace('/player', '')
this.$router.replace(newUrl);

这是另一个 push:

let newUrl = this.$route.path.replace('/player', '')
this.$router.push(newUrl);

您可以使用类似这样的方式导航到父级

<nuxt-link :to="'../' + post.fields.slug">{{post.fields.title}}</nuxt-link>