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

How to set the view background image in uniapp

coldplay.xixi
coldplay.xixiOriginal
2020-12-08 16:39:0115959browse

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>

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!

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