WeChat applets develop image loading (local, network) instance code

Source: Internet
Author: User
This article mainly introduces detailed information about small program image loading (local, network) instances. For more information, see this article) for more information about instances, see

To display an image in a applet, there are two ways to load the image:

  1. Load local images

  2. Attach network Image

Load local images


 

Src = "/image/arrowright.png" is used to load local image resources. Think about loading a local image in iOS, imageName:, similar.

Attach network Image

It is encapsulated in terms of network loading, including audio and video loading. Directly attach an address to the 'src' property, which is automatically loaded.


 

This imageUrl is the data in the js file.


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

You can also directly write


 

Let's take a look at some attributes of the image.

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:

Thank you for reading this article. I hope it will help you. thank you for your support for this site!

The above is the details of the code of the instance for image loading (local, network) in mini-program development. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.