takePhoto点击报错说未定义并且无法拍照?
发布于 6 年前 作者 zoutao 14958 次浏览 来自 官方Issues

takePhoto()

{

var that = this;

this.ctx.takePhoto

({

quality: ‘high’,

success:(res)=>

{

this.setData

({

src:res.tempImagePath

})

/******上传识别图片*******/

wx.showLoading

({

title: ‘识别中…’,

})

var tempFilePaths = res.tempImagePath

wx.uploadFile

({

url: app.globalData.serverUrl + ‘/c-paizhao/api.php?action=upimg’,

header: { “Content-Type”: “multipart/form-data” },

filePath: tempFilePaths,

name: encodeURI(‘img’),

formData:

{

uid: encodeURI(‘test’)

},

success(res) {

console.log(res)

var dataarr = JSON.parse(res.data);

//console.log(dataarr);

that.setData({ itemdata: dataarr.result })

//that.data.itemdata = dataarr.result;

},

fail: function (error)

{

wx.hideLoading();

wx.showToast

({

title: ‘请求超时’,

icon: ‘loading’,

duration: 2000

});

console.log(error)

},

complete: function ()

{

wx.hideLoading();

}

})

}

})

},

1 回复

你定义ctx了?

回到顶部