<template>
<view class="content">
<map id="map" class="map" :latitude="latitude" :longitude="longitude"></map>
<button @click="click">点击</button>
</view>
</template>
<style scoped lang="scss">
#map {
width: 300px;
height: 300px;
}
</style>
<script>
export default {
data() {
return {
latitude: 23.099994,
longitude: 113.324520,
_mapContext: null
}
},
methods: {
click() {
this._mapContext.getCenterLocation({
success: (res) => {
console.log(res.longitude);
console.log(res.latitude);
console.log(res.scale);
},
});
}
},
onReady() {
this._mapContext = uni.createMapContext("map", this)
}
}
</script>
- 发布:2023-09-20 11:24
- 更新:2024-09-03 13:15
- 阅读:370
产品分类: uniapp/小程序/阿里
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 12.0.1 (21A559)
HBuilderX类型: 正式
HBuilderX版本号: 3.8.12
第三方开发者工具版本号: 版本3.7.13 (3.7.13)
基础库版本号: 2.8.15
项目创建方式: HBuilderX
示例代码:
操作步骤:
上面代码所示, 编译到支付宝小程序,使用真机调试就会报错
上面代码所示, 编译到支付宝小程序,使用真机调试就会报错
预期结果:
正常运行
正常运行
实际结果:
报错vendor.js:4750 [Vue warn]: Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
(found in pages/index/index.vue)
报错vendor.js:4750 [Vue warn]: Property or method "toJSON" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
(found in pages/index/index.vue)
c***@163.com (作者)
已经使用原生支付宝测试 没有问题
2023-09-20 11:47
d***@ayundi.com
这个选择解决了吗,选择还是会有这问题
2024-12-02 16:44