uniapp background-image
时间: 2023-09-05 16:07:54 浏览: 104
To set a background image in a Uniapp project, you can use the `background-image` CSS property. Here are the steps:
1. Create a style tag in the `App.vue` file or in any component that you want to set the background image for.
2. Use the `background-image` property to set the source of the image. You can use a URL or a local image file path.
Example:
```
<template>
<view>
<text>Hello World</text>
</view>
</template>
<style>
view {
background-image: url('/static/background.jpg');
background-size: cover;
background-position: center;
}
</style>
```
In this example, we set the background image of the `view` element to `background.jpg` which is located in the `static` folder. We also set the `background-size` and `background-position` properties to make sure the image covers the entire view and is centered.
You can adjust the CSS properties to fit your project's design.
阅读全文