美文网首页
2018-05-27

2018-05-27

作者: 邹玉加油啊 | 来源:发表于2018-05-27 19:15 被阅读0次

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

    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

          本文链接:https://www.haomeiwen.com/subject/sjhijftx.html