微信小程序Cannot read property ‘$$‘ of undefined

Cannot read property ‘$$’ of undefined

情况简述:

<swiper>
      <block wx:for="{{questions}}" wx:key="*this">
        <swiper-item>
          <view> 
           {{item.q_stem}} 
          view>
          <view> 
            <form name="form" class="form">
              <input type="text" class="input_q_answer">input>
            form>
          view>
          <view hidden="{{is_show_q_answer}}">
            答案:{{this.q_answer}}
          view>
        swiper-item>
      block>
    swiper>
data: {
    questions:[],
    is_show_q_answer:true,
    message:"Hello!",
  },

  onLoad: function (options) {
    var that = this;  
    that.data.questions = JSON.parse(options.data_questions_list);
    console.log(that.data.questions);
  },

页面跳转接收的数据无法正常渲染到页面,也就是wxml中的组件中的数据绑定questions,但是控制台打印数据没有问题,渲染完无报错,但是点击模拟器中的区域控制台会报错Cannot read property '$$' of undefined

解决:数据接收到了没有setData,意味着数据没有真正存储到缓存中,页面也就不会渲染此项数据

onLoad: function (options) {
    var that = this;
    that.data.questions = JSON.parse(options.data_questions_list);
    that.setData({
      questions:that.data.questions
    })
    console.log(that.data.questions);
  },

你可能感兴趣的:(小程序,小程序)