Page({
data: {
latitude: '',
longitude: '',
markers: [{
iconPath: '../../images/ovaddress.png',
id: 0,
latitude: '',
longitude: '',
width: 25,
height: 30
}],
enable_traffic:true
},
})
要修改 markers中latitude和longitude
onLoad:function(options){
this.setData({
'markers[0].longitude': options.longitude,
'markers[0].latitude': options.latitude
})
}
要用单引号引起来。
还有一种数据修改,是未确定是数组中的第几个,要动态修改。格式是如下
{
"code": 200,
"data": {
"data": [{
"_index": "index_userinfo",
"_type": "user_info",
"_id": "14",
"_score": 2,
"_source": {
"user_id": 14,
"head_img": "headimg\/00\/00\/00\/00\/14_normal1557865889.jpeg",
"nickname": "小宝宝",
"platform_id": "7874454",
"accid": "chaipro18600325262",
"describe": "爱学习",
"fans": 63,
"video": 233
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "19",
"_score": 2,
"_source": {
"user_id": 19,
"head_img": "headimg\/00\/00\/00\/00\/19_normal1558093451.png",
"nickname": "Chai3504",
"platform_id": "3784544",
"accid": "chaipro18600213504",
"describe": null,
"fans": 8,
"video": 202
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "22",
"_score": 2,
"_source": {
"user_id": 22,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai8440",
"platform_id": "248375874",
"accid": "chaipro13798428440",
"describe": null,
"fans": 0,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "24",
"_score": 2,
"_source": {
"user_id": 24,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai4452",
"platform_id": "8967867",
"accid": "chaipro13023094452",
"describe": null,
"fans": 0,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "25",
"_score": 2,
"_source": {
"user_id": 25,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai9545",
"platform_id": "23314236",
"accid": "chaipro17822149545",
"describe": null,
"fans": 1,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "26",
"_score": 2,
"_source": {
"user_id": 26,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai2985",
"platform_id": "46753455",
"accid": "chaipro13011062985",
"describe": null,
"fans": 1,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "29",
"_score": 2,
"_source": {
"user_id": 29,
"head_img": "headimg\/f08fd039e026a553c93757d24d8957cb795b75e2.jpeg",
"nickname": "飙车的鱼.@",
"platform_id": "78677545",
"accid": "chaipro18518676962",
"describe": "继续那些美好时光",
"fans": 3,
"video": 2
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "40",
"_score": 2,
"_source": {
"user_id": 40,
"head_img": "headimg\/00\/00\/00\/00\/40_normal1559424494.jpeg",
"nickname": "Chai0228",
"platform_id": "64598594",
"accid": "chaipro17610670228",
"describe": null,
"fans": 5,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "41",
"_score": 2,
"_source": {
"user_id": 41,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai8892",
"platform_id": "15488481",
"accid": "chaipro13131308892",
"describe": null,
"fans": 0,
"video": 0
},
"statu": 0
}, {
"_index": "index_userinfo",
"_type": "user_info",
"_id": "73",
"_score": 2,
"_source": {
"user_id": 73,
"head_img": "static\/style\/images\/headimg.png",
"nickname": "Chai3276",
"platform_id": "950031",
"accid": "chaipro18831363276",
"describe": null,
"fans": 0,
"video": 0
},
"statu": 0
}],
"count": 297
}
}
修改这个data数据中的某个数据
Page({
data:{
listData:listData//这里的listData指的是上面的数据
},
//点击事件
tab(e){
var index= e.currenTarget.dataset.index
var setListData = 'listData['+index+'].statu'
//要用引号引起来
// index是动态的第几个
//var setListData = 'this.data.listData['+index+'].statu'
//这里不写this.data 是因为下面修改已经指定了thisl
this.setData({
[setListData]:1
//上面申明的变量 在这里要用【】括起来
})
}
})```