微信小程序把玩(三十一)wx.uploadFile(object), wx.downloadFile(object) API

原文:微信小程序把玩(三十一)wx.uploadFile(object), wx.downloadFile(object) API

反正我是没有测通这两个API!!!!不知道用的方式不对还是其他的!!!先记录下回头再说。。。

主要方法:

wx.uploadFile(OBJECT)上传

这里写图片描述

wx.downloadFile(OBJECT)下载

这里写图片描述

wxml

<button type="primary" bindtap="listenerButtonDownLoadFile">下载图片</button> <image src="{{resource}}" style="width:100%; height: 80%"/>

js

Page({ data:{ // text:"这是一个页面" resource: ‘‘ }, onLoad:function(options){ // 页面初始化 options为页面跳转所带来的参数 }, /** * 下载文件 */ listenerButtonDownLoadFile: function() { var that = this; wx.downloadFile({ url: ‘https://t2.27270.com/uploads/tu/201609/240/1mb2dybkw2x.jpg‘, type: ‘image‘, success:function(res){ console.log(res.tempFilePath); that.setData({ resource: res.tempFilePath, }) }, fail:function(err){ console.log(err) }, complete:function(e) { console.log(e) } }) }})

$(function () {
$(‘pre.prettyprint code‘).each(function () {
var lines = $(this).text().split(‘\n‘).length;
var $numbering = $(‘

    ‘).addClass(‘pre-numbering‘).hide();
    $(this).addClass(‘has-numbering‘).parent().append($numbering);
    for (i = 1; i <= lines; i++) {
    $numbering.append($(‘

  • ‘).text(i));
    };
    $numbering.fadeIn(1700);
    });
    });

相关文章