Home > Web Front-end > uni-app > How to set the view background image in uniapp

How to set the view background image in uniapp

coldplay.xixi
Release: 2023-01-13 00:44:09
Original
15969 people have browsed it

Uniapp method to set the view background image: This can be achieved by setting the background or [background-image] attribute of the view. The code is [

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

Recommended ( Free): uni-app development tutorial

How to set the view background image in uniapp:

Yes This is achieved by setting the background or background-image attribute of the view:

<template>
<view class="content" :style="{background: &#39;url(&#39;+imageURL+&#39;)&#39;}">
<!-- 如果是设置background-image则写成:<view class="content" :style="{backgroundImage:                             
        &#39;url(&#39;+imageURL+&#39;)&#39;}"> -->
</view>
</template>
 
<script>
export default {
data() {
return {
imageURL: &#39;/static/navigation/validCode_back.png&#39;
};
}
}
</script>
Copy after login

Related free learning recommendations: Programming Video

The above is the detailed content of How to set the view background image in uniapp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template