In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of WeChat Mini Programs how to use the built-in camera to take photos and upload pictures. The content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this article on how WeChat Mini Programs uses the built-in camera to take photos and upload pictures. Let's take a look.
1.index.wxml
Get a picture
2.index.js
/ / index.js
/ / obtain an application instance
Var app = getApp ()
Page ({
Data: {
TempFilePaths:''
}
OnLoad: function () {
}
Chooseimage: function () {
Var _ this = this
Wx.chooseImage ({
Count: 1, / / default 9
SizeType: ['original',' compressed'], / / you can specify whether it is the original image or the compressed image. Both are available by default.
SourceType: ['album',' camera'], / / you can specify whether the source is a photo album or a camera. It has both by default.
Success: function (res) {
/ / returns the local file path list of the selected photo. TempFilePath can display the picture as the src attribute of the img tag.
_ this.setData ({
TempFilePaths:res.tempFilePaths
})
}
})
}
})
API description:
Let's talk about sourcetype. The default is to get photos from albums and take pictures with a camera. Like the interface in which Wechat now selects pictures, the first frame is to take photos, followed by album photos.
Note here: what is returned is the local path of the picture. If you need to upload the picture to the server, you need to use another API.
Sample code:
Wx.chooseImage ({
Success: function (res) {
Var tempFilePaths = res.tempFilePaths
Wx.uploadFile ({
Url: 'http://example.weixin.qq.com/upload', / / is an example only, not a real interface address
FilePath: tempFilePaths [0]
Name: 'file'
FormData: {
'user': 'test'
}
Success: function (res) {
Var data = res.data
/ / do something
}
})
}
})
This is the end of the article on "how to use WeChat Mini Programs's built-in camera to take photos and upload pictures". Thank you for reading! I believe you all have a certain understanding of "how WeChat Mini Programs uses the built-in camera to take photos and upload pictures". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.