Examples of WeChat mini-app image uploading, and mini-app image uploading

Source: Internet
Author: User

Examples of uploading small program images: Uploading small program Images

1. Learn more about wx. chooseImage (OBJECT)


Ii. Code Programming

Create an uploadimg folder in the pages File

1. Compile the Page Structure: uploadimg. wxml

<View class = "container" style = "padding: 1rem; "> <button type =" primary "bindtap =" chooseimage "> image retrieval </button> <image src =" {tempFilePaths} "mode =" aspecFill "style =" width: 100%; height: interval RPX; margin: 1rem 0; "/> </view>


2. Set Data: uploadimg. js

// Obtain the application instance var app = getApp () Page ({data: {tempFilePaths: '',},/*** upload image */chooseimage: function () {var _ this = this; wx. chooseImage ({count: 1, // 9 by default // you can specify the source image or compressed image. Both have sizeType: ['original', 'compressed '] by default. // you can specify whether the source is an album or a camera. By default, both of them have sourceType: ['alipay', 'camera '], and // return the list of local file paths of the selected photo, tempFilePath can be used as the src attribute of the img label to display the image success: function (res) {_ this. setData ({tempFilePaths: res. tempFilePaths })}})}})


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

Related Article

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.