项目场景:
在使用vue+uni-app开发微信小程序的时候,调试报错:解析 JSON 失败: TypeError: Cannot read property ‘push’ of undefined
报错如下:
问题描述
以下是出问题的代码:
data() {
return {
fileLists: [],
}
}
// 上传文件
chooseMessageFile() {
var uid = this.uid
wx.chooseMessageFile({
count: 1, // 默认9
type: 'file',
// extension: ['.zip', '.docx', '.doc', '.pdf', 'txt', '.csv', '.xlsx', '.ppt', '.pptx'],
success: function (res) {
console.log(res)
const tempFilePaths = res.tempFiles[0].path;
const tempFileName = res.tempFiles[0].name;
wx.uploadFile({
url: BASE_API_URL + '/Upload/upload', //接口地址
filePath: tempFilePaths,
name: 'file',
formData: {
'uid': uid
},
success: (res) => {
try {
const jsonData = JSON.