vue?底部footer導(dǎo)航組件問(wèn)題
Vue底部footer導(dǎo)航組件
底部導(dǎo)航一定要用路徑!!! 賊關(guān)鍵
舉個(gè)例子:
你隨便定義了一個(gè)變量, flag : 0 跳轉(zhuǎn)首頁(yè), falg:1,跳轉(zhuǎn)我的,
底部導(dǎo)航的組件不可能全項(xiàng)目使用, 點(diǎn)擊我的頁(yè)面 這個(gè)時(shí)候flag 已經(jīng)變成了1,
從我的頁(yè)面進(jìn)入詳情頁(yè),從詳情頁(yè)返回的時(shí)候,雖然路由沒(méi)有變,但是flag 已經(jīng)初始化成了0,
我們的判斷條件沒(méi)辦法自定義,每次從詳情頁(yè)返回的時(shí)候都會(huì)被初始化,
!!! 判斷一定要用路徑
$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" :style="{color:$route.path==='/dashboard/analysis'?'rgb(18,139,232)':'rgba(0, 0, 0, 0.65)'}" >首頁(yè)</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" :style="{color:$route.path==='/dashboard/ToExamine'?'rgb(18,139,232)':'rgba(0, 0, 0, 0.65)'}" >審核</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" :style="{color:$route.path==='/dashboard/mine'?'rgb(18,139,232)':'rgba(0, 0, 0, 0.65)'}" >我的</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 h3 { 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)說(shuō)明的文字 ? ? ? footerMsgCopyright: 'Copyright ? 2020-2021 xxxx平臺(tái) - Powered By ', ? ? ? // 單位 ? ? ? footerMsgName: 'xxxx實(shí)驗(yàn)室' ? ? } ? } } </script>
<style scoped> .app-foot { ? /* footer 固定在頁(yè)面底部 */ ? 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)用組件
主頁(yè)面設(shè)定高度時(shí),要把footer的高度空出來(lái),其style可以如下:
<style> .main-container{ ? /* ?35 = footer ?*/ ? min-height: calc(100vh - 35px); } </style>
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue 子組件與數(shù)據(jù)傳遞問(wèn)題及注意事項(xiàng)
這篇文章主要介紹了Vue子組件與數(shù)據(jù)傳遞問(wèn)題及需要注意事項(xiàng),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-07-07vue 中 beforeRouteEnter 死循環(huán)的問(wèn)題
這篇文章主要介紹了vue beforeRouteEnter 死循環(huán)的問(wèn)題,在文章末尾給大家補(bǔ)充介紹了vue中beforeRouteEnter使用的誤區(qū),需要的朋友可以參考下2019-04-04vue中input type=file上傳后@change事件無(wú)效的解決方案
這篇文章主要介紹了vue中input type=file上傳后@change事件無(wú)效的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-05-05