收藏
回答

wx.chooseLocation 获取地址后,res.longitude值赋值undefined?

大家好,我使用wx.chooseLocation 获取地址后,res.latitude,res.longitude 值赋值给自定义变量,代码如下:

  getLocalPath: function (e) {

    var that = this; 

    wx.chooseLocation({

      success: function (res) {

        console.log(res//获取位置

        that.setData({

          // localPath: res.address,

          latitudeX: res.latitude,

          longitudeY: res.longitude,

          markers: [{

            id: 1,

            latitude: res.latitude,

            longitude: res.longitude,

            iconPath: '../images/Map-pin 6.png',

            callout: {

              content: _('提醒:如果获取的地址有误,请拖动选择地址'),

              bgColor: "#fff",

              padding: "5px",

              borderRadius: "2px",

              borderWidth: "1px",

              borderColor: "#07c160",

            }

          }],

        });

        console.log(res.latitude)

        console.log(res.longitude)

        console.log(that.data.latitudeX)

        console.log(that.data.latitudeY)

      },

    });

  },


最终打印赋值情况,结果如下:

{errMsg: "chooseLocation:ok", name: "", address: "", latitude: 43.84367, longitude: 87.574}

43.84367

87.574

43.84367

undefined

明明获取到了,为什么赋值后undefined?

回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2023-06-06

    longitudeY 你是认真的吗

    2023-06-06
    有用
    回复 1
    • Cherish every day
      Cherish every day
      发表于移动端
      2023-06-06
      我错了,😱😱😱
      2023-06-06
      回复
登录 后发表内容