使用chooseMedia获取文件路径, tempFiles参数为怎么是字符串, 不是数组?

小程序 文章 2020-08-19 18:21 1117 0 全屏看文

AI助手支持GPT4.0

使用chooseMedia获取文件路径, tempFiles参数为怎么是字符串, 不是数组?Use chooseMedia to get the file path. How is the tempFiles parameter a string, not an array?

使用chooseMedia获取文件路径, tempFiles参数为怎么是字符串, 不是数组?

wx.chooseMedia

拿到数据:

tempFiles:"[{"tempFilePath":"wxfile://tmp_bc97fa9f6888753d5736eee78e81824bed9fd9eedb90eaee.jpg","size":"53623"},{"tempFilePath":"wxfile://tmp_bb5028555afa308bbc06f414047093046b61b1c45dcd52a3.jpg","size":"12408"}]"


微信;7.0.0

手机: 锤子OC1.5

手机系统: v6.7.4

wx.chooseMedia Get data: tempfiles: "[{" tempfilepath ":" wxfile: / / tmp_ bc97fa9f6888753d5736eee78e81824bed9fd9eedb90 eaee.jpg ","size":"53623"},{"tempFilePath":"wxfile://tmp_ Bb5028555afa308bbc06f414047093046b61b1c45dcd52a3. JPG "," size ":" 12408 "}]" wechat; 7.0.0 mobile phone: hammer oc1.5 mobile phone system: v6.7.4

回答:

简单:

好吧, 这个问题,已经解决.

拿到数据后, 转换一下

let tempFiles = res.tempFilesif (typeof tempFiles == 'string') {  tempFiles = JSON.parse(tempFiles)}
卢霄霄:

虽然可以转。不过我也觉得应该是API内部自己转好才对。。

Butterfly。:

JSON.parse()下?

-EOF-

AI助手支持GPT4.0