zoukankan      html  css  js  c++  java
  • 组装数据- 对象里面是key:value, value里面是数组的形式,如 {key:[aa,bb], key:[cc,dd]}

    组合后 对象里面是key:value,value里面是数组的形式{key:[aa,bb], key:[cc,dd]}
    var chinaGeoCoordMap = {
    '无锡市': [121.4648, 31.2891],
    '廊坊市': [119.5313, 29.8773],
    "金华市": [118.8062, 31.9208],
     
    第2个参数以数组的形式传递的
    this.add(this.centerdata[i].city,[this.centerdata[i].x,this.centerdata[i].y])
     data: {
                  centerdata:[
                     {"city": "无锡市","clusterID": 1, "x": 120.7485913653,"y": 31.809979797058332},
                     {"city": "廊坊市","clusterID": 2,"x": 130.7485913653,"y": 39.215436433250005},
                     {"city": "金华市","clusterID": 3,"x": 140.7485913653,"y": 29.190387826775}
                  ]
                },
      created() {
                for(var i=0;i<this.centerdata.length;i++){
                  this.add(this.centerdata[i].city,[this.centerdata[i].x,this.centerdata[i].y]);//传参是重点
                }
              },
              
              methods: {
                  add(key,value){
                    let keyValue={}
                    keyValue[key]=value;
                    console.log(keyValue)
                   }
              },


  • 相关阅读:
    合并区间
    编程团体赛
    寻找数组的中间位置
    翻转链表2
    链表翻转
    CF1237H. Balanced Reversals
    arc108E
    agc028D
    CF1446D. Frequency Problem
    CF1439D. INOI Final Contests
  • 原文地址:https://www.cnblogs.com/IwishIcould/p/11355548.html
Copyright © 2011-2022 走看看