How to implement image preview function in WeChat mini program

亚连
Release: 2018-06-08 15:51:47
Original
2834 people have browsed it

This article mainly introduces the image preview function of the WeChat applet in detail. It has certain reference value. Interested friends can refer to it.

This article shares the implementation of the WeChat applet for everyone. The specific code for image preview is for your reference. The specific content is as follows

Rendering

How to implement image preview function in WeChat mini program

Principle

  • Usage wx.chooseImage selects a local image;

  • Use wx.previewImage to preview the image.

WXML

     
Copy after login

WXSS

page{background-color: #efeff4;} .tui-preview-img{ width: 200rpx; height: 120rpx; }
Copy after login

JS

Page({ data: { previewImageArr:[] }, previewImage(e){ var self = this; wx.chooseImage({ count:8, success(res) { var tempFilePaths = res.tempFilePaths; self.setData({ previewImageArr: tempFilePaths}); } }) }, changePreview(e){ var self = this; wx.previewImage({ current: e.currentTarget.dataset.src, urls: self.data.previewImageArr }) } })
Copy after login

Note

wx The parameters current and urls of .previewImage must be http links.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of how to use components and their functions in Vue.js?

Migrate AngularJS1.x application to React (detailed tutorial)

How to implement the shopping cart ball parabola in vue 2.0

The above is the detailed content of How to implement image preview function in WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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!