真机JSON.parse(decodeURIComponent无效
发布于 6 年前 作者 xiayin 6767 次浏览 来自 问答

},onLoad: function(options) {

that = this;

var company = JSON.parse(decodeURIComponent(options.item));

console.log(“options=”, options);

console.log(“company=”,company);

开发工具正常,真机获取不到参数

右边是真机,company为空,options.item是有参数的,请问下是bug吗?

2 回复

它只是打印在下一行了吧……

好吧,我看错了,真正的问题是坐标显示不出来,大大帮我看下

开发工具可以显示,华为不显示坐标

var that;

var app = getApp();

Page({

data: {

markers: [{

iconPath: “/pages/images/wz2.png”,

id: 0,

latitude: 23.099994,

longitude: 113.324520,

width: 24,

height: 24

}],

// polyline: [{

//   points: [{

//     longitude: 113.3245211,

//     latitude: 23.10229

//   }, {

//     longitude: 113.324520,

//     latitude: 23.21229

//   }],

//   color: “#FF0000DD”,

//   width: 2,

//   dottedLine: true

// }],

controls: [{

id: 1,

iconPath: ‘/pages/images/kh.png’,

position: {

left: 0,

top: 300 - 50,

width: 50,

height: 50

},

clickable: true

}]

}, onLoad: function (options) {

that = this;

wx.getLocation({

success: function(res) {

console.log(“获取本地位置=”,res);

var latitude = “markers.latitude”;

var longitude = “markers.longitude”;

that.setData({

[latitude]: res.latitude,

[longitude]: res.longitude

})

},

})

},regionchange(e) {

console.log(e.type)

},

markertap(e) {

console.log(e.markerId)

},

controltap(e) {

console.log(e.controlId)

}

})

|{{markers.latitude}}|{{markers.longitude}}|

<map id=“map” longitude="{{markers.longitude}}" latitude="{{markers.latitude}}" scale=“14” controls="{{controls}}" bindcontroltap=“controltap” markers="{{markers}}" bindmarkertap=“markertap” polyline="{{polyline}}" bindregionchange=“regionchange” show-location style=“width: 100%; height: 300px;”></map>

回到顶部