vue設(shè)置頁面背景及背景圖片簡單示例
更新時間:2023年08月11日 11:43:39 作者:liyinchi1988
這篇文章主要給大家介紹了關(guān)于vue設(shè)置頁面背景及背景圖片的相關(guān)資料,在Vue項(xiàng)目開發(fā)中我們經(jīng)常要向頁面中添加背景圖片,文中通過代碼示例介紹的非常詳細(xì),需要的朋友可以參考下
本地靜態(tài)圖片
<template>
<view class="max">
<image src="../../static/bg.png" mode=""></image>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.max{
image{
z-index:-1;
width:100%;
height:100%;
position: fixed;
top:0;
}
}
</style>cdn圖片
<template>
<view class="">
<view class="max">
<image
src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-59f27697-00c5-4f1e-8c67-bb56e1e19e78/653c2495-cb7b-49a7-b6cb-f048e16fa5a7.jpg"
mode=""
></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.max{
image{
z-index:-1;
width:100%;
height:100%;
position: fixed;
top:0;
}
}
</style>設(shè)置背景色
<template>
<view class="container"> //最外層
<view class="bg-colore"></view> //此標(biāo)簽為最外層view標(biāo)簽的第一個子標(biāo)簽
<view class="content"></view>
</view>
</template>
<script>
</script>
</style>
.bg-colore{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #f4f4f4;
z-index: -1;
}
<style>實(shí)戰(zhàn)-PC web登錄頁

實(shí)戰(zhàn)-小程序登錄頁
<template>
<view class="container">
<image class="bg-img" :src="imgSrc"></image>
<view class="content"></view>
</view>
</template>
<script>
export default {
name: "index",
data() {
return {
imgSrc: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-59f27697-00c5-4f1e-8c67-bb56e1e19e78/653c2495-cb7b-49a7-b6cb-f048e16fa5a7.jpg',
}
}
}
</script>
<style>
.bg-img {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
</style>
總結(jié)
到此這篇關(guān)于vue設(shè)置頁面背景及背景圖片的文章就介紹到這了,更多相關(guān)vue設(shè)置頁面背景及圖片內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
基于Vue3+西瓜視頻播放器(xgplayer)移動端直播解決方案
在現(xiàn)代前端開發(fā)中,視頻播放功能越來越常見,從在線教育到娛樂平臺都離不開高質(zhì)量的視頻播放器,這篇文章主要介紹了基于Vue3+西瓜視頻播放器(xgplayer)移動端直播的相關(guān)資料,需要的朋友可以參考下2026-02-02
vue-cli創(chuàng)建項(xiàng)目時由esLint校驗(yàn)導(dǎo)致報錯或警告的問題及解決
這篇文章主要介紹了vue-cli創(chuàng)建項(xiàng)目時由esLint校驗(yàn)導(dǎo)致報錯或警告的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-05-05
vue 實(shí)現(xiàn)數(shù)字滾動增加效果的實(shí)例代碼
最近做了個項(xiàng)目需要做數(shù)字滾動增加的效果,剛開始接到這個項(xiàng)目還真是懵了,后來發(fā)現(xiàn)實(shí)現(xiàn)代碼很簡單的,下面小編給大家?guī)砹藇ue 實(shí)現(xiàn)數(shù)字滾動增加效果的實(shí)例代碼,需要的朋友參考下吧2018-07-07

