vue button按钮进行链接转跳、转跳传值以及取值

一、请求页A:element组件 button按钮 跳转并传值

1.在src/router/index.js中 定义vue文件的路由

    {
      path: 'AAA/BBB',
      component: () => import('@/views/modules/AAA/BBB'),
      name: 'BBB',
      meta: { title: '标题' }
    }

2.在button按钮定义点击事件

      <div class="buttonList">
        <el-button type="warning" @click="judgeURL">详情</el-button>
        <el-button type="warning">XXX</el-button>
        <el-button type="warning">OOO</el-button>
      </div>

3.在点击事件的方法中,定义转跳和参数赋值

 judgeURL () {
    //BBB 是在路由中定义的name
    this.$router.push({name: 'BBB', query: {id: this.id}})
    },

二、

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是一个简单的示例,演示如何使用Vue制作两个来回转跳的网页。 首先,您需要创建两个Vue组件,一个用于第一个页面,另一个用于第二个页面。以下是一个简单的示例: ```html <!-- 第一个页面 --> <template> <div> <h1>欢迎来到第一页</h1> <button @click="goToPage2">到第二页</button> </div> </template> <script> export default { methods: { goToPage2() { this.$router.push('/page2'); } } } </script> ``` ```html <!-- 第二个页面 --> <template> <div> <h1>欢迎来到第二页</h1> <button @click="goToPage1">回到第一页</button> </div> </template> <script> export default { methods: { goToPage1() { this.$router.push('/'); } } } </script> ``` 在这两个组件中,我们分别定义了一个按钮,用于在两个页面之间进行转跳。在第一个页面的按钮中,我们使用`this.$router.push('/page2')`命令将路由切换到第二个页面。在第二个页面的按钮中,我们使用`this.$router.push('/')`命令将路由切换回第一个页面。 接下来,您需要在Vue的路由器中定义这两个页面的路由。以下是一个简单的示例: ```javascript import Vue from 'vue' import Router from 'vue-router' import Page1 from '@/components/Page1' import Page2 from '@/components/Page2' Vue.use(Router) export default new Router({ routes: [ { path: '/', name: 'Page1', component: Page1 }, { path: '/page2', name: 'Page2', component: Page2 } ] }) ``` 在这里,我们使用Vue路由器定义了两个路由,一个对应第一个页面,另一个对应第二个页面。要访问第一个页面,我们访问`/`路径;要访问第二个页面,我们访问`/page2`路径。 最后,您需要在Vue应用程序中引入路由器,并将其传递给Vue实例。以下是一个简单的示例: ```javascript import Vue from 'vue' import App from './App' import router from './router' Vue.config.productionTip = false new Vue({ el: '#app', router, template: '<App/>', components: { App } }) ``` 在这里,我们在Vue实例中引入了路由器,并将其传递给Vue实例的`router`选项。现在,您应该可以在浏览器中访问您的Vue应用程序,并在两个页面之间进行来回转跳了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值