微信小程序开发 ForInStatement expected node to be of a type [“VariableDeclaration”,“LVal”]
报错内容
unknown file: Property left of ForInStatement expected node to be of a type [“VariableDeclaration”,“LVal”] but instead got undefined
问题描述
当升级微信小程序开发工具到1.06.2504010后,原有代码编译时没有问题,但上传时报
unknown file: ... Property left of ForInStatement expected node to be of a type ["VariableDeclaration","LVal"] but instead got undefined ...
问题解决
最简单的处理方式: for 嵌套循环的时候,用let定义循环变量即可
将
export const letVar = (obj,arr)=>{
arr.forEach(item=>{
for (var p in obj.a){
for(var q in item.obj){
}
}
})
}
改成
export const letVar = (obj,arr)=>{
arr.forEach(item=>{
for (let p in obj.a){
for(let q in item.obj){
}
}
})
}