關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼_第1頁
關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼_第2頁
關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼_第3頁
關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼_第4頁
關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

第關于vue自適應布局(各種瀏覽器,分辨率)的示例代碼目錄1.前言2.vue的布局風格2.1vue3需要配合elementplus進行布局2.2src下面創(chuàng)建layout文件夾3.測試效果4.總結

1.前言

spa頁面的layout布局對于前端項目的影響至關重要,在我們進行web端開發(fā)的時候,前端的各種大小屏幕,各種內核的瀏覽器不同,會導致我們的頁面呈現(xiàn)出不一樣的效果,如何進行更好的取舍,怎么能夠達到產(chǎn)品對于系統(tǒng)展示效果的滿意度,其實我們要前端有一套布局理念,這種理念指導我們如何進行優(yōu)雅布局,怎么才能不被不合理的需求左右。理念分為以下幾點:

整體布局,上左右風格,或者上下風格符合或者復雜的上菜單,左菜單,右內容風格,符合spa的菜單操作方式菜單nav部分固定寬度,配合收起,展開效果;頭部固定高度,內容區(qū)域flex:1;版本部分固定高度,固定位置內容區(qū)域需要適應不同的分辨率,做瀏覽器的適配需要適配瀏覽器的百分比縮放的問題

預覽圖片如下:

現(xiàn)在布局實現(xiàn)的是頭,左側菜單,尾部固定,內容區(qū)域自適應布局的方案,最重要的是需要解決的是main里面的適應分辨率,瀏覽器內核的問題,往下看??

2.vue的布局風格

2.1vue3需要配合elementplus進行布局

安裝$npminstallelement-plus--save

引入main.ts

import{createApp}fromvue

import{createPinia}frompinia

importAppfrom./App.vue

importrouterfrom./router

importElementPlusfromelement-plus

importelement-plus/dist/index.css

import./assets/main.css

constapp=createApp(App);

app.use(ElementPlus);

app.use(createPinia());

app.use(router);

app.mount(#app

2.2src下面創(chuàng)建layout文件夾

入口文件layoutIndex.vue,三個子組件

layoutIndex入口文件較為重要:

scriptsetuplang="ts"

importlayoutHeaderfrom"./layoutHeader.vue";

importlayoutMainfrom"./layoutMain.vue";

importlayoutFooterfrom"./layoutFooter.vue";

importmenufrom"./menu";

import{RouterLink}from"vue-router";

/script

template

div

el-container

el-headerlayout-header/layout-header/el-header

el-container

el-asidewidth="200px"

nav

RouterLink

v-for="(item,index)inmenu"

:key="'menu'+index"

:to="item.url"

{{item.title}}{{index+1}}/RouterLink

/nav

/el-aside

el-container

el-mainlayout-main/layout-main/el-main

el-footerlayout-footer/layout-footer/el-footer

/el-container

/el-container

/el-container

/div

/template

style

margin:0;

padding:0;

.common-layout{

height:100vh;

.el-container{

overflow:hidden;

.el-container.is-vertical{

height:100%;

.nav-class{

display:flex;

flex-direction:column;

height:100%;

align-items:center;

.nav-classa{

min-height:35px;

line-height:35px;

color:#fff;

.nav-classa:hover{

color:rgb(151,219,50);

.nav-classa:focus{

color:rgb(151,219,50);

.el-aside{

background-color:lightslategrey;

/style

頭部文件layoutHeader

template

divheader/div

/template

style

.el-header{

margin:0;

padding:0;

height:68px;

background-color:aliceblue;

text-align:center;

line-height:68px;

/style

layoutFooter文件代碼

template

divfooter/div

/template

style

.el-footer{

margin:0;

padding:0;

height:68px;

background-color:azure;

text-align:center;

line-height:68px;

/style

main文件代碼,就是路由放置區(qū)域:

scriptsetuplang="ts"

import{RouterView}from"vue-router";

/script

template

divRouterView//div

/template

style

.el-main{

overflow:auto;

height:100%;

/style

滾動效果:頭部尾部不動,css控制,flex布局,沒有position布局

3.測試效果

谷歌瀏覽器,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論