組裝數據- 對象里面是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)
               }
          },



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM