vue底部导航

<template>
  <div class="footer">
    <div class="foot">
      <div class="bottom-tab">
        <div class="tab-item" @click="switchTo('/job')">
          <img :src="'/job' === $route.path|| '/' === $route.path? tabBarImgArr[0].selected : tabBarImgArr[0].normal" alt="职位">
          <span :class="{footSelect: '/job' === $route.path}">职位</span>
        </div>
        <div class="tab-item" @click="switchTo('/company')">
          <img :src="'/company' === $route.path ? tabBarImgArr[1].selected : tabBarImgArr[1].normal" alt="公司">
          <span :class="{footSelect: '/company' === $route.path}">公司</span>
        </div>
        <div class="tab-item" @click="switchTo('/message')">
          <img :src="'/message' === $route.path ? tabBarImgArr[2].selected : tabBarImgArr[2].normal" alt="消息">
          <span :class="{footSelect: '/message' === $route.path}">消息</span>
        </div>
        <div class="tab-item" @click="switchTo('/my')">
          <img :src="'/my' === $route.path ? tabBarImgArr[3].selected : tabBarImgArr[3].normal" alt="我的">
          <span :class="{footSelect: '/my' === $route.path}">我的</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name:"foot",
    data() {
      return {
        tabBarImgArr:[
          {selected:require("@/assets/img/ic_main_tab_find_pre.png"),normal:require("@/assets/img/ic_main_tab_find_nor.png")},
          {selected:require("@/assets/img/ic_main_tab_company_pre.png"),normal:require("@/assets/img/ic_main_tab_company_nor.png")},
          {selected:require("@/assets/img/ic_main_tab_contacts_pre.png"),normal:require("@/assets/img/ic_main_tab_contacts_nor.png")},
          {selected:require("@/assets/img/ic_main_tab_my_pre.png"),normal:require("@/assets/img/ic_main_tab_my_nor.png")},
        ]
      };
    },

    methods:{
      switchTo: function (path) {
        this.$router.replace(path)
      }
    }
  };
</script>
<style scoped>
  .bottom-tab{
    position: fixed;
    bottom: 0;
    left: 0;
    display: flex;
    border-top: 1px solid #D9D9D9;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .bottom-tab .tab-item{
    flex: 1;
    text-align: center;
  }
  .bottom-tab .tab-item img{
    display: block;
    width: 30%;
    margin: 0 auto;
  }
  .bottom-tab .tab-item span{
    font-size: 12px;
    color: #B3B3B3;
  }
  .footSelect{
    color: #58CDC6!important;
  }
</style>

 

### 创建底部导航栏 在 Spring Boot 和 Vue 项目中创建底部导航栏涉及前端部分的开发工作,主要集中在 Vue.js 的组件编写上。对于此操作,在构建具有底部导航栏的应用程序时,通常会利用现有的 UI 库简化样式和交互逻辑的设计。 #### 使用 Ant Design Vue 实现底部导航栏 考虑到希望实现的是底部导航栏而非顶部,Ant Design Vue 提供了一个灵活的方式来定制化页面结构[^2]。为了使底部导航栏能够适用于整个应用而不局限于单个视图内重复定义,推荐的做法是在 `App.vue` 文件中引入并配置全局使用的脚手架布局。 ```html <template> <a-layout> <!-- 中间内容区域 --> <router-view></router-view> <!-- 底部导航栏 --> <a-footer style="text-align: center;"> NewBee Mall ©2023 Created by Your Company Name </a-footer> </a-layout> </template> <script> export default { name: 'App' } </script> <style scoped> /* 自定义样式 */ </style> ``` 上述代码展示了如何使用 Ant Design Vue 来布置一个简单的页脚作为应用程序的底部导航栏。这里的关键在于 `<a-footer>` 组件被放置于最外层的 `<a-layout>` 容器之下,从而确保其位于所有其他内容之后显示为页面底部的一部分。 #### 调整页面布局以适应底部导航栏 当直接将官方提供的布局代码粘贴至项目中时可能会遇到一些问题,比如路由失效或某些元素未能按预期呈现。这主要是因为默认情况下这些模板可能并未考虑与其他框架(如 Vue Router)协同工作的需求。因此,调整如下: - 将公共组件(例如头部、侧边栏以及现在的底部导航栏)移出具体页面组件之外; - 确保仅在一个地方管理整体布局,通常是 `App.vue` 或类似的根级文件; - 对于需要跨多个页面共享的内容(像这里的底部),应尽可能早地将其加入渲染树中以便在整个应用范围内可见; 这样做不仅有助于保持代码整洁有序,而且也使得维护更加容易。 #### 设置自定义样式 为了让底部导航栏更好地融入网站的整体风格,可以通过 CSS 添加额外的样式规则。如果发现添加后的页面显得不够和谐,则可能是由于原有样式的冲突所致。此时应当仔细审查所引用的外部资源链接,并适当修改本地样式表中的相关属性直至达到满意的效果。 ```css .ant-layout-footer { background-color: #f5f5f5; padding: 16px 0; color: rgba(0, 0, 0, .45); } ``` 以上示例说明了怎样通过覆盖默认类名 `.ant-layout-footer` 来改变底栏的颜色和其他视觉特性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值