1. Route jump
1. First introduce the API - useRouter
import { useRouter } from 'vue-router'
on the page that needs to be jumped. 2. Define the router variable on the jump page
//先在setup中定义 const router = useRouter()
3. Use router.push to jump to the page
// 字符串 router.push('home') // 对象 router.push({ path: 'home' }) // 命名的路由 router.push({ name: 'user', params: { userId: '123' }}) // 带查询参数,变成 /register?userId=123 router.push({ path: 'register', query: { userId: '123' }})
4. If there are parameters, introduce API–useRoute
import { useRoute } from 'vue-router'
on the receiving page 5. Define the variable route on the receiving page to get the passed Variable
//首先在setup中定义 const route = useRoute() //query let userId=route.query.userId; //params let userId=route.params.userId;
2. Pay attention to when passing parameters on the page
1. If path is provided, params will be ignored, but this is not the case for query. At this time, you need to provide the name of the route or complete it by handwriting path with parameters
const userId = '123' router.push({ name: 'user', params: { userId }}) router.push({ path: `/user/${userId}` }) // 这里的 params 不生效 router.push({ path: '/user', params: { userId }})
2. The above rules also apply to the to attribute of the router-link component
3. If the destination is the same as the current route, only the parameters have changed (for example, from a user data to another /users/1 -> /users/2), you need to use beforeRouteUpdate to respond to this change (such as grabbing user information)
The above is the detailed content of How to use router routing to implement jump parameters in vue3. For more information, please follow other related articles on the PHP Chinese website!

前端有没有现成的库,可以直接用来绘制 Flowable 流程图的?下面本篇文章就跟小伙伴们介绍一下这两个可以绘制 Flowable 流程图的前端库。

vue不是前端css框架,而是前端JavaScript框架。Vue是一套用于构建用户界面的渐进式JS框架,是基于MVVM设计模式的前端框架,且专注于View层。Vue.js的优点:1、体积小;2、基于虚拟DOM,有更高的运行效率;3、双向数据绑定,让开发者不用再去操作DOM对象,把更多的精力投入到业务逻辑上;4、生态丰富、学习成本低。

Vue3如何更好地使用qrcodejs生成二维码并添加文字描述?下面本篇文章给大家介绍一下Vue3+qrcodejs生成二维码并添加文字描述,希望对大家有所帮助。

本篇文章我们来了解 Vue2.X 响应式原理,然后我们来实现一个 vue 响应式原理(写的内容简单)实现步骤和注释写的很清晰,大家有兴趣可以耐心观看,希望对大家有所帮助!


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.