Vue页面跳转是通过路由跳转的

7 篇文章 0 订阅

Vue页面跳转是通过路由跳转的

一、
    this.$router.push({
                    path: '/operate/add-manage/add',
                    //  参数
                    params: {
                        id:id
                    }
       })

二、

// table组件中的跳转
    {
              title: '用户账号',
              key: 'userMobile',
              align: 'center',
              render: (h, params) => {
                return h('div', [
                  h('span', params.row.userMobile),
                  h('Button', {
                    props: {
                      type: 'primary',
                      size: 'small'
                    },
                    style: {
                      marginLeft: '10px'
                    },
                    on: {
                      click: () => {
                        // this.show(params.index)
                        this.$router.push({
                          path: '/user/manage/user-detail',
                          query: { id: params.row.userId, type: 0 }
                        })
                      }
                    }
                  }, '查看')
                ])
              }
            },

三、

//  请求接口的跳转
setTimeout(() => {
     this.$router.push({ path: '/order/order-manage/raise-cattle' });
 }, 1000);

在根目录中
有个 router 文件夹 --》
有个 routers.jswen 文件打开里面有路由配置

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 3中,你可以使用Vue Router来进行页面跳转,包括跳转到子路由页面。以下是一种常见的实现方式: 首先,确保你已经安装了Vue Router,并将其配置到你的Vue应用中。 接下来,在你的路由配置文件(通常是`router/index.js`)中,定义你的路由和子路由: ```javascript import { createRouter, createWebHistory } from 'vue-router'; const routes = [ { path: '/', name: 'Home', component: Home }, { path: '/parent', name: 'Parent', component: Parent, children: [ { path: 'child', name: 'Child', component: Child } ] } ]; const router = createRouter({ history: createWebHistory(), routes }); export default router; ``` 在上面的例子中,我们定义了一个父级路由`/parent`,并在它下面定义了一个子路由`/parent/child`。 在你的父级组件中(例如`Parent.vue`),你可以使用`<router-link>`标签来创建一个链接到子路由的导航链接: ```html <template> <div> <h1>Parent Component</h1> <router-link :to="{ name: 'Child' }">Go to Child</router-link> <router-view></router-view> </div> </template> ``` 上述代码中,我们使用`<router-link>`将文本"Go to Child"包裹起来,并设置了`to`属性为`{ name: 'Child' }`,这将链接到我们在路由中定义的子路由。 最后,在你的子组件中(例如`Child.vue`),你可以按照需要进行渲染: ```html <template> <div> <h2>Child Component</h2> <!-- 子组件内容 --> </div> </template> ``` 这样,当用户点击父组件中的导航链接时,Vue Router将会自动加载并渲染子组件。 请确保你根据自己的项目结构和需求进行适当的调整。希望这个示例能帮到你!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值