vue如何將導(dǎo)航欄、頂部欄設(shè)置為公共頁(yè)面
vue設(shè)置導(dǎo)航欄 頂部欄為公共頁(yè)面
首先全局引入需要的兩個(gè)組件
import LeftSide from '@/components/leftSide/index'; import CrmHeader from '@/components/crmHeader/index'; Vue.component('LeftSide',LeftSide); Vue.component('CrmHeader',CrmHeader);
然后在MainApp.vue中添加如下代碼
<!-- 實(shí)際運(yùn)用場(chǎng)景中,登錄注冊(cè)頁(yè)面我們不希望出現(xiàn),所以用keep-alive結(jié)合$route.meta來(lái)實(shí)現(xiàn)這個(gè)功能 --> <div v-if="$route.meta.keepAlive"> ?? ?<LeftSide></LeftSide> ? ? <CrmHeader></CrmHeader> </div>
在router.js,用meta控制顯示
{ ? ? name: 'home', ? ? path: '/home', ? ? component: Home, ? ? meta:{ ? ? ? // true: 側(cè)邊欄與頂部欄顯示 false: 不顯示 ? ? ? keepAlive: true ? ? } }
vue實(shí)現(xiàn)頂部導(dǎo)航欄設(shè)計(jì)
效果圖
完整代碼:
<template> <div class="title"> <div class="title-left"> <div class="title-left-image"></div> <router-link to="/unusedOrder"> <span class="">導(dǎo)航一</span> </router-link> <router-link to="/usedOrder"> <span class="">導(dǎo)航二</span> </router-link> <router-link to="/usedOrder"> <span class="">導(dǎo)航三</span> </router-link> <router-link to="/advices"> <span class="">導(dǎo)航四</span> </router-link> <router-link to="/evaluate"> <span class="">導(dǎo)航五</span> </router-link> </div> <div> </div> <div class="serch"> <div contenteditable class="inputType" placeholder='請(qǐng)輸入文字'></div> <div class="button">搜索</div> </div> <div class="title-right"> <div class="title-right-image"></div> <router-link to="/unusedOrder"> <span class="">導(dǎo)航六</span> </router-link> <router-link to="/usedOrder"> <span class="">導(dǎo)航七</span> </router-link> <router-link to="/advices"> <span class="">導(dǎo)航八</span> </router-link> </div> </div> </template>
<script> export default { name:'Title', } </script>
<style> .title{ margin-left: 0px; height: 48px; width: 100%; background-color:#fff; border-bottom: 1px solid #DCDCDC; display: flex; justify-content:space-between; } .title-left{ width: 580px; height: 48px; margin-left: 0; background:#fff; display: flex; } .title-left-image{ height: 48px; width:120px } span{ font-size: 16px } a{ width: 70px; height: 48px; color: black; margin: 0px 10px; text-decoration: none; line-height: 48px; text-align: center } a:hover{ background-color: #BEBEBE; } .serch{ height: 32px; width: 500px; background-color:#fff; margin: auto; display: flex; } .inputType{ width:400px; height: 30px; text-indent: 1em; line-height: 34px; background-color: #fff; border: 1px solid black; border-top-left-radius: 17px; border-bottom-left-radius: 17px; font-size: 12px; } .inputType:focus{ outline: none; border: 1px solid rgb(230, 32, 213); } .button{ color: #fff; text-align: center; background: rgba(204, 51, 0, 1); border-left:1px solid rgba(0, 0, 0, 0.45); width:100px; height: 32px; line-height: 34px; border-top-right-radius: 18px; border-bottom-right-radius: 18px } .title-right{ width: 380px; height: 48px; display: flex; } .title-right-image{ width: 40px; height: 40px; border: 1px solid black; border-radius: 20px; margin: auto ; margin-left: 40px; } </style>
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue項(xiàng)目中運(yùn)用webpack動(dòng)態(tài)配置打包多種環(huán)境域名的方法
本人分享一個(gè)vue項(xiàng)目里,根據(jù)命令行輸入不同的命令,打包出不同環(huán)境域名的方法。需要的朋友跟隨小編一起看看吧2019-06-06vue學(xué)習(xí)筆記之指令v-text && v-html && v-bind詳解
這篇文章主要介紹了vue學(xué)習(xí)筆記之指令v-text && v-html && v-bind詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-05-05Vue?element-ui中表格過(guò)長(zhǎng)內(nèi)容隱藏顯示的實(shí)現(xiàn)方式
在Vue項(xiàng)目中,使用ElementUI渲染表格數(shù)據(jù)時(shí),如果某一個(gè)列數(shù)值長(zhǎng)度超過(guò)列寬,會(huì)默認(rèn)換行,造成顯示不友好,下面這篇文章主要給大家介紹了關(guān)于Vue?element-ui中表格過(guò)長(zhǎng)內(nèi)容隱藏顯示的實(shí)現(xiàn)方式,需要的朋友可以參考下2022-09-09Vue3關(guān)于響應(yīng)式數(shù)據(jù)類型詳解(ref、reactive、toRef、及toRefs)
這篇文章主要介紹了Vue3關(guān)于響應(yīng)式數(shù)據(jù)類型(ref、reactive、toRef、以及toRefs),本文結(jié)合示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-01-01詳解如何解決vue開(kāi)發(fā)請(qǐng)求數(shù)據(jù)跨域的問(wèn)題(基于瀏覽器的配置解決)
這篇文章主要介紹了詳解如何解決vue開(kāi)發(fā)請(qǐng)求數(shù)據(jù)跨域的問(wèn)題(基于瀏覽器的配置解決),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11vue不用window的方式如何刷新當(dāng)前頁(yè)面
這篇文章主要介紹了vue不用window的方式如何刷新當(dāng)前頁(yè)面,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11Vue3 composition API實(shí)現(xiàn)邏輯復(fù)用的方法
本文主要介紹了Vue3 composition API實(shí)現(xiàn)邏輯復(fù)用的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08element-plus日歷(Calendar)動(dòng)態(tài)渲染以及避坑指南
這篇文章主要給大家介紹了關(guān)于element-plus日歷(Calendar)動(dòng)態(tài)渲染以及避坑指南的相關(guān)資料,這是最近幫一個(gè)后端朋友處理一個(gè)前端問(wèn)題,elementUI中calendar日歷組件內(nèi)容進(jìn)行自定義顯示,實(shí)現(xiàn)類似通知事項(xiàng)的日歷效果,需要的朋友可以參考下2023-08-08