微信小程序设计答题 界面无法显示题目
var json = [
{
"question": "1+1=?",
"option": {
"A": "1",
"B": "2",
"C": "3",
"D": "4",
},
"true": "2", // 正确答案
"scores": 10, // 分值
"checked": false // 默认没有选中
},
{
"question": "2+2=?",
"option": {
"A": "2",
"B": "4",
"C": "6",
"D": "8",
},
"true": "B",
"scores": 10,
"checked": false
},
{
"question": "3+3=?",
"option": {
"A": "2",
"B": "4",
"C": "6",
"D": "8",
},
"true": "C",
"scores": 10,
"checked": false
},
{
"question": "5+5=?",
"option": {
"A": "10",
"B": "7",
"C": "6",
"D": "8",
},
"true": "A",
"scores": 10,
"checked": false
},
{
"question": "4+4=?",
"option": {
"A": "2",
"B": "4",
"C": "6",
"D": "8",
},
"true": "D",
"scores": 10,
"checked": false
},
{
"question": "6+6=?",
"option": {
"A": "12",
"B": "14",
"C": "16",
"D": "18",
},
"true": "A",
"scores": 10,
"checked": false
},
{
"question": "7+7=?",
"option": {
"A": "12",
"B": "14",
"C": "16",
"D": "18",
},
"true": "B",
"scores": 10,
"checked": false
},
{
"question": "8+8=?",
"option": {
"A": "12",
"B": "14",
"C": "16",
"D": "18",
},
"true": "C",
"scores": 10,
"checked": false
},
{
"question": "9+9=?",
"option": {
"A": "12",
"B": "14",
"C": "16",
"D": "18",
},
"true": "D",
"scores": 10,
"checked": false
},
{
"question": "2+3=?",
"option": {
"A": "2",
"B": "5",
"C": "6",
"D": "8",
},
"true": "B",
"scores": 10,
"checked": false
}
]
module.exports = {
questionList: json
}
// app.js
var jsonList = require('data/json.js');
App({
globalData:{
questionList:jsonList.questionList
}
})
<view class="page">
<view>
<view class="timu">
{{index+1}}、{{questionList[index].question}}
每题{{questionList[index].scores}}分
view>
view>
<view>
<radio-group bindchange="radioChange" wx:if="{{questionList[index].type == 1}}">
<label wx:for="{{questionList[index].option}}"wx:for-index="key" wx:for-item="value">
<radio value="{{key}}" checked="{{questionList[index].checked}}"/>{{key}}、{{value}}
label>
radio-group>
<view>
<button bindtap='nextSubmit' wx:if="{{index==questionList.length-1}}">提交button>
<button bindtap='nextSubmit' wx:else>下一题button>
view>
view>
view>
1.没看到有type这个字段
2.index没有定义