tab组件

作者: Amy_yqh | 来源:发表于2018-06-12 10:44 被阅读0次

tab组件

<template>
    <div class="tab">
      <router-link tag="div" class="tab-item" to="/recommend">
        <span class="tab-link">推荐</span>
      </router-link>
      <router-link tag="div" class="tab-item" to="/singer">
        <span class="tab-link">歌手</span>
      </router-link>
      <router-link tag="div" class="tab-item" to="/rank">
        <span class="tab-link">排行</span>
      </router-link>
      <router-link tab="div" class="tab-item" to="/search">
        <span class="tab-link">搜索</span>
      </router-link>
    </div>
</template>

<script>
    export default {

    }
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
  @import "~common/stylus/variable"
  .tab
    display: flex
    height: 44px
    line-height: 44px
    font-size: $font-size-medium
    .tab-item
      flex: 1
      text-align: center
      .tab-link
        padding-bottom: 5px
        color: $color-text-l
      &.router-link-active
        .tab-link
          color: $color-theme
          border-bottom: 2px solid $color-theme
</style>

效果图


image.png

默认进来的时候选择第一个tab,在路由中配置path为“/”为根目录时,重定向到指定的组件

routes[
  {
      path:'/',
      redirect:'/recommend'
    },
{
      path: '/recommend',
      component: Recommend
    },
]

相关文章

网友评论

      本文标题:tab组件

      本文链接:https://www.haomeiwen.com/subject/nhlleftx.html