亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development Two image loading methods for WeChat mini programs

Two image loading methods for WeChat mini programs

Jul 15, 2020 pm 04:30 PM

Two image loading methods for WeChat mini programs

In the WeChat applet, to display an image, there are two image loading methods:

1. Load local images

2. Load network images

Load local images

<image class="widget__arrow" src="/image/arrowright.png" mode="aspectFill">
</image>

src="/image/arrowright.png" This sentence is Load local image resources. Think about loading local images in iOS, imageName:, similar.

Loading network pictures

WeChat is still very good at loading the network. , including the loading of voice and video. Directly attach the address to the 'src' attribute and it will be loaded automatically.

 <image class="image_frame" src="{{imageUrl}}" mode="aspectFill">
 </image>

This imageUrl is the data in the js file

data:{
    imageUrl:"http://img1.3lian.com/2015/w7/85/d/101.jpg"
},

It can also be written directly as

<image class="image_frame" src="http://img1.3lian.com/2015/w7/85/d/101.jpg" mode="aspectFill">
</image>

Let’s take a look at some attributes of the image

It should be noted that: The default width of the image component is 300px and the height is 225px

src is used in the above code.

mode has 12 modes, 3 of which are zoom modes and 9 are cropping modes.

#For specific instructions, it is recommended to read the official documentation, which is very detailed. Click to open the link

It’s very simple.

##Left issues

In practice, I want to implement such a function: click a button to have the image reload.

I don’t know how to directly operate the image in the js file. You may know it in the future. If anyone knows the method, please feel free to leave a message.

Supplement

The remaining questions have been answered.

In the key response method, you can directly use setData to set a new address for imageUrl

downLoadImage:function(event){
    console.log(event)
    var that = this;
    this.setData({
        imageUrl:"http://h.hiphotos.baidu.com/zhidao/pic/item/6d81800a19d8bc3ed69473cb848ba61ea8d34516.jpg"
    })
  }
The effect is as follows:


Recommended: "

小program development tutorial"

The above is the detailed content of Two image loading methods for WeChat mini programs. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72