Page外var声明问题?
Page({ data:{ data:[], //添加变量,用于前端页面显示 json:[], }, onLoad(options) { wx.request({ url: 'http://localhost/Data.php', data:{}, method:'GET', header:{ 'content-Type':'application/json' }, success:res=>{ console.log(res) this.setData({ data:res.data, json:[ { "question":res.data[0], "option":{ "A":"非常频繁", "B":"经常", "C":"偶尔", "D":"从不", }, "true":"A", "type":1, "scores":10, "checked":false }, { "question":res.data[1], "option":{ "A":"非常频繁", "B":"经常", "C":"偶尔", "D":"从不", }, "true":"A", "type":1, "scores":10, "checked":false }, { "question":"3你是否经常伤害自己?", "option":{ "A":"非常频繁", "B":"经常", "C":"偶尔", "D":"从不", }, "true":"A", "type":1, "scores":10, "checked":false }, { "question":"4你是否经常伤害自己?", "option":{ "A":"非常频繁", "B":"经常", "C":"偶尔", "D":"从不", }, "true":["A","C","D"], "type":2, "scores":10, "checked":false }, ] }); console.log(this.data.json.length)//有效语句 console.log(this.data.json[0])//有效语句 } }); }, }) var Json = Page.this.data.json module.exports= { questionList:Json } /////////////////////////////////////////////////////////////////////////////////////// 错误出现在最后的var Json = Page.this.data.json这句上,想要通过模块导出变量json [图片]