代码如下: <template> <view> <view class="" v-for="(item, i) in Question1" :key="i"> <view class="cate-lv2-title">{{item}}</view> <view class="cate-lv2-title" v-for="(item, j) in Option1[i]" :key="j"> {{item}} </view> <input class="input1" type="text" placeholder="请输入答案" v-model="answer1[i]" /> </view> <view class="">3333</view> </view> </template> <script> export default { data() { return { id:0, Question1: [], NUM: 0, Option1: [], Answer1: [], answer1: [], points1: 0, Question2: [], Option2: [], Answer2: [], answer2: [], points2: 0, Question3: [], Option3: [], Answer3: [], answer3: [], points3: 0, }; }, onLoad(option) { wx.cloud.init() this.id=option.id this.getdata() }, methods:{ getdata:function(e){ var _this=this const db = wx.cloud.database() var _this=this var num1 = 0 var num2 = 0 var num3 = 0 db.collection('question1').get().then(res => { for (var i = 0; i < res.data.length; i++) { if (res.data[i].zhangjie == 1) { _this.Question1[i] = res.data[i].question this.Option1[i] = res.data[i].option this.Answer1[i] = res.data[i].answer // this.NUM=this.NUM+1 num1 = this.Question1.length } } console.log("Question1",this.Question1) for (var i = 0; i < res.data.length - num1; i++) { var num = i + num1 if (res.data[num].zhangjie == 2) { this.Question2[i] = res.data[num].question this.Option2[i] = res.data[num].option this.Answer2[i] = res.data[num].answer } num2 = num1 + this.Question2.length } for (var i = 0; i < res.data.length - num2; i++) { var num = i + num2 if (res.data[num].zhangjie == 3) { this.Question3[i] = res.data[num].question this.Option3[i] = res.data[num].option this.Answer3[i] = res.data[num].answer } num3 = num2 + this.Question3.length } }) console.log(this.Question1) } } } </script> <style lang="scss"> </style>
微信开发者工具控制台可以显示数据,但AppData里没有?控制台: [图片] AppData: [图片]
2023-05-20