在微信开发者工具中我是这样写的
onShow: function(options) {
this.globalData.scene = options.scene;
var scene = ['1007', '1008'];
var indexof = scene.indexOf(options.scene);
if (indexof == -1) {
//场景为在数组中的处理
} else {
//场景不在数组中的处理
}
},
然而在真机上却不是这样,必须要这样写
onShow: function(options) {
this.globalData.scene = options.scene;
var scene = [1007, 1008];
var indexof = scene.indexOf(options.scene);
if (indexof == -1) {
//场景为在数组中的处理
} else {
//场景不在数组中的处理
}
},
不知道细心地同学有没有发现写法哪有不同
var scene = [1007, 1008];
在开发者工具中这样判断是不行。但是真机是可以的,
var scene = ['1007', '1008'];
这样写在开发者工具中这样判断是可以的。但是真机是不可以的,
所以遇到这个坑,当然也可以将数组中每一项转成数字,或者将数字转成字符串处理也是可以的;
碰到这种情况一定要真机多测试几遍