**
* 生命周期函数–监听页面加载
*/
onLoad: function (options) {
console.log(“页面加载开始。。。。。。。。。。”)
changeColor();
// this.data.txtArray[1].changeColor=true
},
changeColor: function (res) {
var txtArray = [];
for (var i = 0; i < this.data.txtArray.length; i++) {
if (res.target.id == this.data.txtArray[i].id) {
txtArray[i] = { id: this.data.txtArray[i].id, changeColor: true, txt: this.data.txtArray[i].txt }
console.log(“ture”)
} else {
txtArray[i] = { id: this.data.txtArray[i].id, changeColor: false, txt: this.data.txtArray[i].txt }
console.log(“false”)
}
}
this.setData({
txtArray: txtArray
})
},
报错:
changeColor is not defined;at pages/login/homePage page lifeCycleMethod onLoad function
ReferenceError: changeColor is not defined