Accessing Array Object Property In Vue.js
Given the following array in vue.js: packageMaps: Object packageMap_0: Object Id: 16 PackageType: 'flag_list' ProductCode: 'F-BannerBase' packageMap
Solution 1:
If your response data is BIG in size, convert that response data to another object with (key,value)
as {product Id
: packageMap_x_object
}, like below, thus retrieval will be fast
let newPackageMaps = {
"F-BannerBase": packageMap_0_Object
"F-TeardropBanner":packageMap_1_Object
..........
..........
}
populatePackageList(productCode) {
//---------- more code----------------let packageMapItem = newPackageMaps[productCode]?
newPackageMaps[productCode]:null;
//---------- more code ----------
}
OR in simple you can use a for..in loop,
for (let packageMap inthis.packageMaps) {
if(packageMap.ProductCode == input_ProductCode ){
// more codebreak;
}
}
Post a Comment for "Accessing Array Object Property In Vue.js"