Home  >  Article  >  Web Front-end  >  What should I do if the background image set by uniapp cannot be displayed?

What should I do if the background image set by uniapp cannot be displayed?

藏色散人
藏色散人Original
2021-01-26 11:02:118856browse

Solution to the problem that the background image set by uniapp cannot be displayed: 1. Check the image size, and then convert it to base64 format for use or put it on the server and reference it from the network address; 2. Change the local background image Modify the reference path to an absolute path starting with the "~@" symbol.

What should I do if the background image set by uniapp cannot be displayed?

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

Recommendation (free): uni-app tutorial

The background image of uni-app is not displayed on the mobile phone?

uni-app’s solution to the problem of being unable to load local images [dynamic loading of background images *the only solution]

Special note: Don’t forget [`url(${indexBackgroundImage})`]

<template>
	<view class="index" :style="{backgroundImage:`url(${indexBackgroundImage})`,backgroundSize: &#39;cover&#39;}">
		<!--你的内容-->
	</view>
</template>
 
<script>
	
	import indexBackgroundImage from "@/static/img/account_index.jpg"
	
	export default {
		data() {
			return {
				indexBackgroundImage:indexBackgroundImage
			}
		},
		methods: {
			
		}
	}
</script>
 
 
<style lang="scss" scoped="">
</style>

The above is the detailed content of What should I do if the background image set by uniapp cannot be displayed?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn