Home > Mobile >  Strange question: small program onload method cannot access data data, the great god, please give di
Strange question: small program onload method cannot access data data, the great god, please give di

Time:09-19

1, the list page jump to emp

 showEmp (e) 
{
Let the openid=e.c. with our fabrication: urrentTarget. Dataset. The openid;
The console. The log (" page spread and openid: ", openid);

//wx. ShowToast ({title: 'the OpenID:' + OpenID, icon: 'none', duration: 3000});
//setTimeout (function () {wx. HideToast ()}, 2000);

Wx. NavigateTo ({
Url: '/pages/emp/emp? Openid='+ openid,
})

}


2 emp. Within the js onl oad, according to a lot of data query and then prepare to page


 Page ({

/* *
* the initial data of the page
*/
Data: {
Tiwen: []
},


/* *
* life cycle function - listening page load
*/
OnLoad: function (options) {
Let the openid=options. The openid;
Enclosing getEmpList (openid);
The console. The log (" body temperature Data this week 2: "+ this. Data. Tiwen);



}

/* *
* access to specify the openid temperature data this week
*
*/
GetEmpList: function (openid)
{
var now=new Date();
Var d1=now. GetFullYear () + "/" + enclosing getWeek (0);
Var d7=now. GetFullYear () + "/" + enclosing getWeek (7);
Let tw=[];
Var that=this;

Db. Collection (' emps). The where ({
Indate: cm. Gte (new Date (d1). GetTime ()). And (cm) lt (new Date (d7). GetTime () - 3)),
_openid: openid
})
.get ({
Success: the function (res) {
The console. The log (" obtain specified openid temperature data: ", res. Data);
for (var i=0; i The console. The log (" body temperature: "+ res. Data [I] tiwen);
Tw [I]=res. Data [I] tiwen;
}
The console. The log (" temperature data this week 1: "+ tw);

That the setData ({
Tiwen: tw, //an error here
});

}

});

},



3/error code

 always read a property 'tiwen of undefined; At "pages/emp/emp" page lifeCycleMethod onl oad function 
TypeError: always read the property 'tiwen of undefined
The at ye. onl oad (http://127.0.0.1:24981/appservice/pages/emp/emp.js:66:42)
The at ye. & lt; Anonymous> (WAService. Js: 1:13 53019)
__callPageLifeTime__ at ye p. (52764) WAService. Js: 1:13
At Tt (WAService. Js: 1:13 67714)
The at WAService. Js: 1:13 69208
The at xt (WAService. Js: 1:13 69254)
Ats Function. & lt; Anonymous> (WAService. Js: 1:13 74768)
The at i. & lt; Anonymous> (WAService. Js: 1:13 44283)
At appropriate precautions MIT (WAService. Js: now 5256)
At the Object. Emit (WAService. Js: 1:6 07614)








CodePudding user response:

A sofa, a great god come in, please.

CodePudding user response:

I also encountered similar problems, the key is that the setData ({
Tiwen: tw, & lt; Span style="color: # FF0000;">//an error here & lt;/span>
}); Don't know why old said tiwen undefined, looking forward to the great god to reassure

CodePudding user response:

You put the returned res print it out and see, there was a question field
  • Related