【uni-app】将图片作为页面的背景

【uni-app】将图片作为页面的背景

事情是这样的,最近考完了浙江专升本,我就在忙毕设,有几个页面我需要设置页面的背景图片。但我尝试用普通html网页设置背景图片的方式在uni-app里面写,却发现并不能适用。我绞尽脑汁,终于把这个问题完美解决了,故准备记录一下,方便以后查阅。

代码如下:

<template>
	<view class="body">
	
	</view>
</template>

<script>
</script>

<style scoped>
	.body{
      
      
		background:url("../../static/loginback.png");
		width:100%;
		height:100%;
		position:fixed;
		background-size:100% 100%;
	}
</style>

这样写,就以图片为背景图片了。
在这里插入图片描述
页面的其他标签都在body里面写就好了。比如写的这个登录页。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_50216991/article/details/130464047
今日推荐