2018-05-27

关于对象访问的几个问题:

var currentFeatureModels = {"modelId":22,"modelNo":"P1000001","sealShape":"椭圆形","sealSize":"18*18","sealMaterial":"光敏","sealPattern":"五角星","price":1000}

var key = sealMaterial

console.log('currentFeatureModels》》》》》》' + currentFeatureModels.sealMaterial)///直接访问属性

用变量去访问: console.log('currentFeatureModels》》》》》》' + currentFeatureModels.key )是把key当成里面的一个属性去读取,肯定不行,只有按如下去访问:
console.log('currentFeatureModels》》》》》》' + currentFeatureModels[key])////要先读key变量的值

你可能感兴趣的:(2018-05-27)