設置背景
1、設置背景色:
<template>
<view class="container"> //最外層
<view class="bg-set"></view> //此標簽為最外層view標簽的第一個子標簽
<view class="content"></view>
</view>
</template>
.bg-set{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #f4f4f4;
z-index: -1;
}
2、設置背景圖
<template>
<view class="container">
<image class="bg-set" src="https://img-1258.file.myqcloud.com/bg.png"></image>
<view class="content"></view>
</view>
</template>
.bg-set{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
以上想法引自 https://www.cnblogs.com/swordLaughsHeaven/p/12118562.html 並略作修改
官網方式:
1、在 uni-app 中不能使用 * 選擇器。
2、page 相當於 body 節點,例如
<!-- 設置頁面背景顏色 -->
page {
background-color:#ccc;
}
或者在globalSTyle中配置: https://uniapp.dcloud.io/collocation/pages?id=style
個人沒仔細研究,覺得局限還是有的
