vant组件库tabbar页面切换,跳转子页面tabbar隐藏,子页面跳转

目录:
在这里插入图片描述
App.vue:

<template>
  <div>
    <router-view/>
    <van-tabbar route active-color="#07c160" v-if="$route.meta.showTab">
      <van-tabbar-item icon="gift-o" to="/past">Past</van-tabbar-item>
      <van-tabbar-item icon="like-o" to="/">Present</van-tabbar-item>
      <van-tabbar-item icon="envelop-o" to="/feature">Feature</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

router->index.js:

import Vue from 'vue'
import VueRouter from 'vue-router'

import Past from '@/views/Past/Past.vue'
import Present from '@/views/Present/Present.vue'
import Feature from '@/views/Feature/Feature.vue'
// import Story from '@/views/Past/Story/Story.vue'

// 把 VueRouter 安装为 Vue 的插件
Vue.use(VueRouter)

const routes = [{
    path: '/past',
    component: Past,
    meta: {
      showTab:true
    },
    // children: [{
    //   path: '/past/story',
    //   name: 'Story',
    //   component:  () => import('@/views/Past/Story/Story.vue'),
    //   meta: {
    //     // showTab:true,
    //     // title: '故事',
    //     // icon: 'el-icon-document'
    //   },
    // }], 
  },
  {
    path: '/',
    component: Present,
    meta: {
      showTab:true
    },
  },
  {
    path: '/feature',
    component: Feature,
    meta: {
      showTab:true
    },
  },
  {
    path: '/past/story',
    component: () => import('@/views/Past/Story/Story.vue')
  },
  {
    path: '/past/storya',
    component: () => import('@/views/Past/Storya/Storya.vue')
  }
]


// 创建路由实例对象
const router = new VueRouter({
  routes
})

export default router

Past.vue:
点击图片跳转到 story 子页面

<router-link to="/past/story">
  <img :src="item.img" alt="" style="width: 100%;height:100%;">
</router-link>

story.vue

<template>
  <div>
    story---
    {{story}}
    <van-button type="default" @click="fanhui()">返回</van-button>
    <van-button type="default" @click="toStorya()">跳转到storya</van-button>
  </div>
</template>

<script>
import StoryInfo from '@/components/Story/StoryInfo.vue'

export default {
  name: 'Story',
  data() {
    return {
      story: [1,2,3]
    }
  },
  created(){
    console.log(this.story)
  },
  component: {
    StoryInfo
  },
  methods:{
    fanhui(){
      this.$router.push('/past')
    },
    toStorya(){
      this.$router.push('/past/storya')
    }
  }
}
</script>

<style>

</style>

storya.vue:

<template>
  <div>
    story---
    {{story}}
    <van-button type="default" @click="fanhui()">返回</van-button>
  </div>
</template>

<script>
import StoryInfo from '@/components/Story/StoryInfo.vue'

export default {
  name: 'Story',
  data() {
    return {
      story: [12,12,21]
    }
  },
  created(){
    console.log(this.story)
  },
  component: {
    StoryInfo
  },
  methods:{
    fanhui(){
      this.$router.back();
    }
  }
}
</script>

<style>

</style>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值