```where, imageUrl"> How to pass the uniapp image address to VIEW-uni-app-php.cn
Home> Web Front-end> uni-app> body text

How to pass the uniapp image address to VIEW

PHPz
Release: 2023-04-18 15:49:28
Original
1030 people have browsed it

In the process of developing applications using Uniapp, we often need to display images on the page. Many times, we need to obtain the image address through the interface and then display it on the page. So, how to pass the image address to VIEW? This article will introduce it to you in detail.

1. Use the img tag

In Uniapp, you can use the HTML img tag to display images. You can use the following code in the template:

Copy after login

where imageUrl is the address of the image. In Vue, you can pass data by binding a variable.

         
Copy after login

By binding imageUrl in data, it can be passed easily.

2. Use background images

In addition to using the img tag, you can also use CSS background-image to set a background image. The advantage of this method is that you can set the position, size and other styles of the picture, giving you greater freedom. Use the following code in the template:

Copy after login

where imageUrl is also the address of the image. Binding can also be passed through data in Vue.

         
Copy after login

3. Use the uni-image component

In addition, Uniapp also provides the uni-image component for displaying pictures. Using the uni-image component, you can also set the placeholder image for image loading and error. Use the following code in the template:

Copy after login

where imageUrl is also the address of the image. loadingImage and errorImage are placeholder images during loading and error respectively. Binding can also be passed through data in Vue.

         
Copy after login

The above is how to pass the image address to VIEW in uniapp. You can choose according to the actual situation. If you just want to simply display the image, you can use the img tag or background image; if you need to set the placeholder image during loading and error, you can use the uni-image component.

The above is the detailed content of How to pass the uniapp image address to VIEW. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!