路由传参的方式
- 动态路由传参
{
path: "/home/:id/:name/:age’,
component: home
} - params传参
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="./vue.js"></script>
<script src="./vue-router.js"></script>
<title>Document</title>
<style>
.router-link-active{
color: rgb(118, 160, 1);
}
</

本文介绍了Vue Router中的编程式导航,即如何通过代码实现路由跳转,并详细讲解了动态路由参数的使用,包括在路由配置中设置动态段`/home/:id/:name/:age`以及如何通过`params`传递参数。
最低0.47元/天 解锁文章
1882





