问题是
InitComponents
函数什么都不知道
app.locals
本地应用程序
app.locals.componentData
作为参数
功能:
function InitComponents(componentData) {
for( var i = 0; i < componentData.categories.length; i++ ){
alert("in loop!"+i+"-"+componentData.categories[i].categoryName);
if(componentData.categories[i].categoryName.match(itemId)){
alert("here:"+componentData.categories[i].parameters.length);
createParameterList(newID,componentData.categories[i].parameters);
}
}
}
InitComponents(app.locals.componentData);
现在知道什么了
componentData
是。
app
通过
req.app
:
myMiddlewareFunction((req, res, next) => {
const app = req.app;
initComponents(app.locals.componentData);
// some other logic
})