swiper vue 初始化方法_vue-router页面传值及接收值

9ef7987a6bb7afd42cbfda8136e04d2d.png
前端写页面,我们经常需要从A页面传值给B页面,比如下面的场景

2862ce965283a33cf27656d11874862c.png
点击“充值中”跳转到下一个页面,使tabbar中的页面与其对应

8ecb1f74f1d797a52ab7a40ec87945da.png
需要上个页面传值

下面来实现下:

A页面——My.vue

在去“order”页面的方法中通过params传值current=1

<template>
<div id="app">
...
          <div @click="gotoWaitpay">
            <img src="../../static/images/order_icon1.png"
                 alt />
            <span>待支付</span>
          </div>
...
</div>
</template>

<script>
export default {
  data () {
    return {
    }
  },
  methods: {
    gotoWaitpay () {
      this.$router.push({
        name: 'Order',
        params: {
          current: 1
        }
      })
    },
  },
}
</script>

B页面——Order.vue

在B页面通过 this.$http://route.params.xxx接收A页面传来的值

<template>
...
</template>

<script>
export default {
  data () {
    return {
      swiper_current: 0,
      tabbar_current: 0,
    }
  },
  methods: {
  },
  created () {
    if (this.$route.params.current) {
      this.tabbar_current= this.$route.params.current
      this.swiper_current = this.$route.params.current
    } else {
    }
  }
}
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值