uni-app设置页面背景及背景图片

设置背景

1、设置背景色:
<template>
    <view class="container">  //最外层
          <view class="bg-set"></view>  //此标签为最外层view标签的第一个子标签
          <view class="content"></view>
    </view> 
</template>

.bg-set{
    position: fixed;
     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;
     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

个人没仔细研究,觉得局限还是有的
原文地址:https://www.cnblogs.com/huihuihero/p/13024701.html