溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

vue底部footer導(dǎo)航組件問題怎么解決

發(fā)布時(shí)間:2022-04-01 11:12:01 來源:億速云 閱讀:429 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要講解了“vue底部footer導(dǎo)航組件問題怎么解決”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“vue底部footer導(dǎo)航組件問題怎么解決”吧!

Vue底部footer導(dǎo)航組件

底部導(dǎo)航一定要用路徑!!! 賊關(guān)鍵

舉個(gè)例子:

你隨便定義了一個(gè)變量, flag : 0 跳轉(zhuǎn)首頁, falg:1,跳轉(zhuǎn)我的,

底部導(dǎo)航的組件不可能全項(xiàng)目使用, 點(diǎn)擊我的頁面  這個(gè)時(shí)候flag 已經(jīng)變成了1,

從我的頁面進(jìn)入詳情頁,從詳情頁返回的時(shí)候,雖然路由沒有變,但是flag 已經(jīng)初始化成了0,

我們的判斷條件沒辦法自定義,每次從詳情頁返回的時(shí)候都會被初始化,

!!! 判斷一定要用路徑

$route.path

<template>
  <div class="footer">
  <div class="costList1" @click="choiceState('/dashboard/Analysis')">
      <img class="costUrl" v-if="$route.path==='/dashboard/analysis'" src="../../assets/img/bot-apply0.png" />
      <img class="costUrl" v-else src="../../assets/img/bot-apply1.png" />
      <div
        class="costName"
        :
      >首頁</div>
    </div>
    <div class="costList1" @click="choiceState('/dashboard/ToExamine')">
      <a-badge :count="this.$store.state.applyNum">
        <img class="costUrl" v-if="$route.path==='/dashboard/ToExamine'" src="../../assets/img/1.png" />
        <img class="costUrl" v-else src="../../assets/img/0.png" />
      </a-badge>
      <div
        class="costName"
        :
      >審核</div>
    </div>
    <div class="costList1" @click="choiceState('/dashboard/mine')">
      <img class="costUrl" v-if="$route.path==='/dashboard/mine'" src="../../assets/img/mine11.png" />
      <img class="costUrl" v-else src="../../assets/img/mine12.png" />
      <div
        class="costName"
        :
      >我的</div>
  </div>
  </div>
</template>
<script>
export default {
  name: 'LayoutFooter',
  data() {
    return {
      applyNum: 0,
      reimbNum: 0,
      wgtVer: ''
    }
}
  methods: {
    choiceState(path) {
      this.$router.push(path)
    }
  }
}
</script>
<style lang="scss" scoped>
.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  height: 58px;
  background: #eff0f6;
  align-items: center;
  .costList1 {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    height: 58px;
    align-items: center;
    img {
      width: 20px;
      height: 22px;
    }
    .costName {
      text-align: center;
    }
  }
}
.ant-carousel >>> .slick-slide {
  text-align: center;
  height: 160px !important;
  line-height: 160px;
  background: #364d79;
  overflow: hidden;
}
.ant-carousel >>> .slick-slide h4 {
  color: #fff;
}
</style>

Vue抽取的footer組件,可復(fù)用

<template>
  <div class="app-foot">
    {{footerMsgCopyright}}
    <span class="source">{{footerMsgName}}</span>
  </div>
</template>
<script>
export default {
  name: 'AppFoot',
  data() {
    return {
      // 版權(quán)說明的文字
      footerMsgCopyright: 'Copyright ? 2020-2021 xxxx平臺 - Powered By ',
      // 單位
      footerMsgName: 'xxxx實(shí)驗(yàn)室'
    }
  }
}
</script>
<style scoped>
.app-foot {
  /* footer 固定在頁面底部 */
  min-height: 35px;
  background-color: #eeeeee;
  width: 100%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.source{
  font-weight: 600;
}
</style>

復(fù)用時(shí)直接調(diào)用組件

主頁面設(shè)定高度時(shí),要把footer的高度空出來,其style可以如下:

<style>
.main-container{
  /*  35 = footer  */
  min-height: calc(100vh - 35px);
}
</style>

感謝各位的閱讀,以上就是“vue底部footer導(dǎo)航組件問題怎么解決”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對vue底部footer導(dǎo)航組件問題怎么解決這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI