简体   繁体   English

在 Nuxt 中如何实现程序化路由?

[英]How to achieve programatic routing in Nuxt?

Nuxt comes with pre-configured router out of the box and we can use <NuxtLink to="/about" prefetch>About page</NuxtLink> . Nuxt带有Nuxt即用的预配置路由器,我们可以使用<NuxtLink to="/about" prefetch>About page</NuxtLink> However, how to achieve programmatic routing?但是,如何实现程序化路由?

The question seems to have a simple and straightforward answer.这个问题似乎有一个简单而直接的答案。 But sometimes, we end up surfing the web for a long time and landing up on not what we are looking for a lot of time.但有时,我们最终会在网上冲浪很长一段时间,而且登陆的内容并不是我们一直在寻找的内容。

Answer to this question is simple.这个问题的答案很简单。 You can do it in a same way as you do it in normal vue.js app using this.$router.push .您可以使用this.$router.push以与在普通 vue.js 应用程序中相同的方式进行this.$router.push

this.$router.push({ path: val });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM