1.在tempalate下面建設(shè)兩個div,兩個div建設(shè)在同一個div內(nèi)
1 <div class="background"></div> 2 <div class="front"></div>
2.在第一個div內(nèi)添加一個圖片
<
img
?:src="imgSrc" width="100%" height="100%" alt="" />
3.js里面定義圖片的返回路徑 在data {return內(nèi)}因為存放路徑?jīng)]辦法讀取所以就 把類型寫為require
imgSrc:require(
'../../assets/images/bg2.jpg'
)
4.給他倆添加style樣式 z-index是判斷誰是上面的,數(shù)值大的在上面
.background{
????
width:100%;??
????
height:100%;??
/**寬高100%是為了圖片鋪滿屏幕 */
????
z-index:-1;
????
position: absolute;
文章來源:http://www.zghlxwxcb.cn/news/detail-515358.html
}
文章來源地址http://www.zghlxwxcb.cn/news/detail-515358.html
.front{
????
z-index:1;
????
position: absolute;
}
到了這里,關(guān)于給vue的頁面添加背景圖片的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!