AI助手支持GPT4.0
如何将扫码获取的string数据转为json形式?How to convert the string data obtained by scanning the code into json format?
如何将扫码获取的string数据转为json形式?
wx.scanCode({ scanType:['qrCode'], onlyFromCamera: true, success(res){ var data=res.result; console.log(data);})如何将这个data数据转为json形式并通过wx.navigateTo({ url: '/pages/info/info', events: { acceptDataFromOpenedPage: function(data) { console.log(data) }, someEvent: function(data) { console.log(data) } }, success: function(res) { res.eventChannel.emit('acceptDataFromOpenerPage', { data: '数据' }) } })发往另一也页面调用显示
wx. Scancode ({scantype: ['qrcode '], onlyfromcamera: true, / / set that you can only scan with the camera {success (RES) {var data = result. Result; console. Log (data);}) How to convert this data into JSON form and pass it through Wx Navigateto ({URL: '/ pages / Info / Info', events: {/ / add a listener for the specified event to get the data transferred from the opened page to the current page { console.log(data) }, someEvent: function(data) { console.log(data) } }, Success: function (RES) {/ / transfer data to the opened page through eventchannel res.eventchannel.emit ('acceptdatafromopenerpage ', {data:' data '}) }}) send to another page to call the display
如果是字符串里面是json可以用JSON.parse()