uni app 根据选项卡下标跳转对应选项卡页面

一时失言乱红尘 2021-09-07 06:06 646阅读 0赞

A页面根据下标跳转B选项卡的对应位置

  1. <!--A页面 先给一个对应num-->
  2. <view class="night-box">
  3. <view @tap="goincident(0)">1</view>
  4. <view @tap="goincident(1)">2</view>
  5. <view @tap="goincident(2)">3</view>
  6. <view @tap="goincident(3)">4</view>
  7. </view>
  8. //根据页面跳转事件对应状态
  9. goincident(num) {
  10. uni.navigateTo({
  11. url: `../mon-telemetry/mon-telemetry?type=${ num}`
  12. })
  13. }

B页面根据传入的状态,对应显示选项卡页面

  1. <u-navbar :is-back="true" back-icon-color="#fff" title="" :background="background">
  2. <view class="u-tabs-box">
  3. <u-tabs-swiper activeColor="#ffffff" inactive-color="#ffffff" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750" bg-color='#2E95FF'></u-tabs-swiper>
  4. </view>
  5. </u-navbar>
  6. <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
  7. <!-- 遥测越线 -->
  8. <swiper-item class="swiper-item">
  9. <scroll-view scroll-y style="height: 100%;width: 100%;">
  10. <view class="page-box">
  11. <!--内容-->
  12. </view>
  13. </scroll-view>
  14. </swiper-item>
  15. <!--..省略重复代码*3-->
  16. </swiper>
  17. data() {
  18. return {
  19. background: {
  20. backgroundColor: '#2E95FF',
  21. },
  22. list: [{ //选项卡名称
  23. name: '1'
  24. },
  25. {
  26. name: '2'
  27. },
  28. {
  29. name: '3'
  30. },
  31. {
  32. name: '4',
  33. }
  34. ],
  35. current: 0,
  36. swiperCurrent: 0,
  37. tabsHeight: 0,
  38. dx: 0,
  39. };
  40. },
  41. onLoad(option) {
  42. this.current = option.type
  43. this.swiperCurrent = option.type

发表评论

表情:
评论列表 (有 0 条评论,646人围观)

还没有评论,来说两句吧...

相关阅读

    相关 选项

    关于选项卡效果 1. 常规 2. 传参(可设置多个参数值) 3. 回调函数 下面是几种参考方法 常规方法 <!DOCTYPE html>