uploadimages(filePath){
var that=this
var a = filePath.match(/\.[^.]+?$/)
wx.uploadFile({
cloudPath: `codeImg/${Math.random()}_${Date.now()}.${a[1]}`,
filePath:filePath,
name: 'name',
success:res=>{
console.log(" 图片路径",res.fileID)
that.setData({
cloudImg:res.fileID
})
}
上传图片时显示Cannot read property 'match' of undefined?,请高手帮忙解决下,谢谢
这个参数是undefined 为啥是,我可不知道,没代码
wx.showToast({
title: '生成中....',
})
var that = this
wx.cloud.callFunction({
name:"createQRCode",//生成小程序二维码
// name:"wxacode",//生成小程序码
// name: "getUnlimited",//生成小程序二维码
data: {
openid: 'dddddddd',
freshID: 'dafafaasfafasfa'
},
success: res => {
console.log(res)
let fileManager = wx.getFileSystemManager();
let filePath = wx.env.USER_DATA_PATH + '/qr.jpg';
console.log("写入成功",filePath)
fileManager.writeFile({
filePath: filePath,
encoding: "binary",
data: res.result.buffer,
success: res => {
console.log(filePath);
var codeImg = filePath;
wx.hideLoading({})
that.setData({
filePath:filePath
})
that.uploadimages()
}
})
}
})
},