请问微信小程序,将以下代码绑定到view组件上,点击上传图片后为什么报错
upLoadImage: function(event) {
var id = event.currentTarget.id
var that = this
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function(res) {
var tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: '/wx/upload',
filePath: tempFilePaths[0],
name: 'image_file',
success: function (res) {
}
})
},
})
}
错误代码是:
uploadFile:fail Cannot read property '0' of null
感觉是tempFilePaths参数没有传入uploadFile函数中,但是函数中不是应该能读取外层函数的变量吗?
哈士奇WWW
相关分类