We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// 异步得到的数据源,需要先进行缓存,在必要时附加到original上 var data = { productionQueues: [ { addData: 123, otherData: 098 }, { addData: 456, otherData: 789 } ] }; // 为对象追加数据 var extend = []; // 遍历data并在extend中进行缓存 kit.forEach(data.productionQueues, function(value, index) { extend.push(value.addData); }); // [123, 456] var original = { productionQueues: [ { configEnums:[], productNum: "--",// 产品标识号 productId: "--",// 生产管理号/产品管理号 carDescription: "--",// 产品规格 }, { configEnums:[], productNum: "--",// 产品标识号 productId: "--",// 生产管理号/产品管理号 carDescription: "--",// 产品规格 }, ], } // 为original附加数据 kit.forEach(original.productionQueues, function(value, index) { // 赋值对象没有对应extend[index]看不到任何数据 original.productionQueues[index].addData = extend[index]; })
将单纯的数组存储方式改为用单一有效值数据对象进行存储
// 异步得到的数据源,需要先进行缓存,在必要时附加到original上 var data = { productionQueues: [ { addData: 123, otherData: 098 }, { addData: 456, otherData: 789 } ] }; // 为对象追加数据 var extend = []; // 遍历data并在extend中进行缓存 kit.forEach(data.productionQueues, function(value, index) { extend[index] = { addData: value.addData }; }); /* extend:[ { addData:123 }, { addData:456 } ] */ var original = { productionQueues: [ { configEnums:[], productNum: "--",// 产品标识号 productId: "--",// 生产管理号/产品管理号 carDescription: "--",// 产品规格 }, { configEnums:[], productNum: "--",// 产品标识号 productId: "--",// 生产管理号/产品管理号 carDescription: "--",// 产品规格 }, ], } // 为original附加数据 kit.forEach(original.productionQueues, function(value, index) { // 在附加处不需要任何键值 $.extend(true, original.productionQueues[index], extend[index]); })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
目前处理方式
改进处理方式
The text was updated successfully, but these errors were encountered: