微信小程序 json 數據添加新元素

 init: function () {
   var that=this;
 if (json.questions.length > 0) {
  for (var i = 0; i < json.questions.length; i++) {
    json.questions[i]['Question']['ans_sel'] = new Array();
     json.questions[i]['Question']['is_right'] = 2; // 0錯誤 1正確 2 未選擇
    if (json.questions[i]['Question']['question_type_id'] == 2 || json.questions[i]['Question']['question_type_id'] == 1 || json.questions[i]['Question']['question_type_id'] ==3) {
          json.questions[i]['Question']['content'] = json.questions[i].Question.content.split('|');
        };
        //this.questions[i]['ExamQuestion']['is_score'] = false;
      };
    }
 
  },

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章