微信小程序(新手)各位大神多帮助

微信小程序(新手)各位大神多帮助

问题描述:

// text.wxml


点击

//text.js
var flag = true;
Page({
data:{
color : "window"
},
click:function(){
console.log("点击了文字");
if(flag){
color = "window-red";
flag = false;
}else{
color = "window";
flag = true;
}
this.setData({
color
});
},
onLoad:function(options){
//页面初始化 options为页面跳转所带来的参数
console.log("Page onLoad");
},
onReady:function(){
//页面完成渲染
console.log("Page onReady");
},
onShow: function (){
//页面显示
console.log("Page onShow");
},
onHide: function (){
//页面隐藏
console.log("Page onHide");
},
onUnload: function () {
//页面关闭
console.log("Page onUnload");
}
})
错误提示:就是提示我color未定义
VM2084:1 thirdScriptError
color is not defined;at peges/helloworld/helloworld page click function
ReferenceError: color is not defined
at s.click (http://127.0.0.1:53147/appservice/peges/helloworld/helloworld.js:11:13)
at s. (http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:590602)
at s.R (http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:579728)
at at (http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:600703)
at http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:610440
at Function. (http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:610632)
at http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:579090
at http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:291737
at n (http://127.0.0.1:53147/appservice/__dev__/WAService.js:1:170539)
at e (http://127.0.0.1:53147/appservice/appservice?t=1540889261010:1105:19979)
新手求助!

起码 你先在 console.log("点击了文字");前面设置一个let color;吧。。。。

感谢大神指教:我这是刚学微信小程序 没事试试 请问方便加下qq么 有些事想要请教一下