[Mini Programe] Upload Images
Code for upload iamges:
chooseImage: choose the images to upload
previewImage: preview the image and enable slide
- chooseImage() {
- wx.chooseImage({
- count: 3,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: res => {
- let currentImages = res.tempFilePaths
- this.setData({
- images: currentImages
- })
- },
- })
- },
- previewImg(event) {
- let target = event.currentTarget
- let src = target.dataset.src
- wx.previewImage({
- current: src,
- urls: this.data.images
- })
- },
Upload to the server:
- uploadImage(cb) {
- let commentImages = this.data.commentImages
- let images = []
- if (commentImages.length) {
- let length = commentImages.length
- for (let i = 0; i < length; i++) {
- wx.uploadFile({
- url: config.service.uploadUrl,
- filePath: commentImages[i],
- name: 'file',
- success: res => {
- let data = JSON.parse(res.data)
- length--
- if (!data.code) {
- images.push(data.data.imgUrl)
- }
- if (length <= 0) {
- cb && cb(images)
- }
- },
- fail: () => {
- length--
- }
- })
- }
- } else {
- cb && cb(images)
- }
- },
- onInput(event) {
- this.setData({
- commentValue: event.detail.value.trim()
- })
- },
- chooseImage() {
- let currentImages = this.data.commentImages
- wx.chooseImage({
- count: 3,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: res => {
- currentImages = currentImages.concat(res.tempFilePaths)
- let end = currentImages.length
- let begin = Math.max(end - 3, 0) // latest three pictures
- currentImages = currentImages.slice(begin, end)
- this.setData({
- commentImages: currentImages
- })
- },
- })
- },
[Mini Programe] Upload Images的更多相关文章
- Arduino uno R3 ISP刷Rootloader for arduino pro mini
找了好久才发现的,好东西.介绍怎么使用uno对mini 刷Rootloader **SOLUTION** Reinstall the Arduino Pro Mini Bootloader using ...
- Reinstall the Arduino Pro Mini Bootloade ISP(转)
源:Reinstall the Arduino Pro Mini Bootloade ISP To resolve the errors I burned the bootloader to the ...
- arduino pro mini不能下载
刚毕业时就知道arduino,但当时崇拜技术极致,喜欢把单片机的性能用到尽,觉得操作寄存器运行效率高,对arduino 这种高效模式贬为投机取巧,不过其中也一直对arduino 有关注. 随着芯片技术 ...
- elementUI vue upload完整示例
elementUI 和vue 还有axios +java的完整示例, 代码敲了很久, 累死了, 以后用就直接复制了 ,很值吧!!! 1.html <!DOCTYPE html> <h ...
- Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)成功烧录方法
问题: Arduino:1.6.3 (Windows 7), 板:"Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)" Sketch ...
- UMEditor(Ueditor mini)修改图片上传路径
UMEditor(Ueditor mini)修改图片上传路径 imageUp.ashx string pathbase = "/UpLoad/images/"; //保存文件夹在网 ...
- 让MacBook识别noppoo mini 84
让MacBook识别noppoo mini 84 noppoo默认是没有mac驱动的,需要下载一个IOUSBHIDDriverDescriptorOverride否则无法noppoo的键位是识别错误的 ...
- 解决ngnix服务器上的Discuz!x2.5 Upload Error:413错误
1.修改php.ini sudo nano /etc/php5/fpm/php.ini #打开php.ini找到并修改以下的参数,目的是修改上传限制 max_execution_time = 900 ...
- 中大东校小米路由器mini实现inode上网,ipv6 wifi【中大】【东校】【inode】【ipv6】
还有不到4个月就要毕业了,前几天半夜没事捣鼓小米路由没想到竟然实现了wifi的ipv6. 正好又安利了同学一台小米路由mini,从刷机到inode到ipv6全搞了一遍. 这里将教程写出来,服务学弟妹. ...
随机推荐
- 向listview控件中添加数据库数据
//连接字符串 string str = "Data Source=.;Initial Catalog=mu;User ID=sa;Password=111"; //创建数据库连接 ...
- 在C语言中模仿java的LinkedList集合的使用(不要错过哦)
在C语言中,多个数据的储存通常会用到数组.但是C语言的数组有个缺陷,就是固定长度,超过数组的最大长度就会溢出.怎样实现N个数储存起来而不被溢出呢. 学过java的都知道,java.util包里有一个L ...
- vue-devtools是vue浏览器调试工具
开vue官网在vue-生态系统-工具可以看到vue-devtools这个工具: vue-devtools是一款基于chrome游览器的插件,用于调试vue应用,这可以极大地提高我们的调试效率.接下来我 ...
- PyCharm使用指南及更改Python pip源为国内豆瓣
PyCharm基本使用 1.在PyCharm下为python项目配置python本地解释器 setting-->Project:pycharm workspace-->Project In ...
- UVM基础之---------uvm factory机制base
从名字上面就知道,uvm_factory用来制造uvm_objects和component.在一个仿真过程中,只有一个factory的例化存在. 用户定义的object和component types ...
- CommHelper
18位流水号: public static string GenerateTransId(int i) { string transId = DateTime.Now.ToString("y ...
- jmeter元件的作用域和顺序
jmeter是一个开源的性能测试工具,它可以通过鼠标拖拽来随意改变元件之间的顺序以及元件的父子关系,那么随着它们的顺序和所在的域不同,它们在执行的时候,也会有很多不同. jmeter的test pla ...
- SpringBoot中如何使用jpa和jpa的相关知识总结
jpa常用的注解: 注解 解释 @Entity 声明类为实体或表. @Table 声明表名. @Basic 指定非约束明确的各个字段. @Embedded 指定类或它的值是一个可嵌入的类的实例的实体的 ...
- docker搭建日志收集系统EFK
EFK Elasticsearch是一个数据搜索引擎和分布式NoSQL数据库的组合,提过日志的存储和搜索功能. Fluentd是一个消息采集,转化,转发工具,目的是提供中心化的日志服务. Kibana ...
- java string与byte互转
1.string 转 byte[]byte[] midbytes=isoString.getBytes("UTF8");//为UTF8编码byte[] isoret = srt2. ...