首页 > 编程语言 >uni-app:微信小程序:使用位置权限getlocation时报错(hbuilderx 3.7.3)

uni-app:微信小程序:使用位置权限getlocation时报错(hbuilderx 3.7.3)

时间:2023-02-24 14:34:27浏览次数:55  
标签:getlocation 微信 app json res fail uni com

一,getlocation时报错:

代码:
<template>
    <view>
        <button style="width:710rpx;height:80rpx;" @click="openMap">打开地图</button>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                
            }
        },
        methods: {
            openMap(){
                uni.getLocation({
                            success: res => {
                                console.log('location success', res)
                                uni.openLocation({
                                    latitude: res.latitude,
                                    longitude: res.longitude,
                                    scale: 18
                                })
                            },
                            fail:res=>{
                                console.log('location fail', res)
                            }
                        });
            },
        }
    }
</script>
 
<style>
 
</style>
报错:
getLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json
如图:

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: [email protected]

二,解决:

编辑manifest.json 增加一行:
"requiredPrivateInfos": ["getLocation", "chooseLocation"]
如图:

三,测试效果:

三,查看hbuilderx的版本: 

 

 

标签:getlocation,微信,app,json,res,fail,uni,com
From: https://www.cnblogs.com/architectforest/p/17151350.html

相关文章

  • mapper动态代理
    Dao接口的实现类仅仅是通过sqlsession的相关api定位到映射文件mapper中的相应id的sql语句,真正对DB进行操作的工作是由框架通过mapper中的sql完成的。mybatis框架抛开dao的......
  • 微信小程序嵌入H5,从H5获取数据返回小程序页面(wx.miniProgram.postMessage)
    https://www.jianshu.com/p/469d89273a3f 需求:微信小程序使用web-view组件嵌入H5链接,从H5页面中获取某些数据在微信小程序页面中进行处理。微信文档中有web—view......
  • uni-app学习笔记之----页面跳转
    1、声明式跳转<navigatorurl="/pages/detail/detail"><button>跳转至详情页</button></navigator><navigatorurl="/pages/index/index"open-type="switchTab"......
  • 微信小程序与内嵌h5页面之间的参数传递
    https://blog.csdn.net/weixin_46032911/article/details/128506919小程序是采用vue+taroui技术栈1.内嵌h5页面向小程序传参:1h5页面所在文件:h5.vue//页面跳转函数--前......
  • uni-app学习笔记之----不同平台,独立设置
    (不断补充中。。。)1、导航栏2、条件编译不同的条件标记,会被编译到不同的平台开头:【#ifdef】或【#ifndef】+平台名称结尾:【#endif】html中: js中: css中:......
  • APP学习2
    1.相关说明图片资源分类:应用图标:存放在mipmap文件夹中界面中使用的图片资源:存放在drawable文件夹中2.调用   所以在java中可以通过this.getResources().get文......
  • CPU推理|使用英特尔 Sapphire Rapids 加速 PyTorch Transformers
    在最近的一篇文章中,我们介绍了代号为SapphireRapids的第四代英特尔至强CPU及其新的先进矩阵扩展(AMX)指令集。通过使用AmazonEC2上的SapphireRapids服务器......
  • 小case-基于chatgpt的微信自动回复
    微信自动回复基于聊天api的importpyautoguiimportpyperclipimportkeyboardimportrequestsimporttimeprint('程序即将开始,请打开微信!')#检测是否有新消息......
  • 分享手机上一款超多功能的APP(含428个功能):宇宙工具箱
    无意中在网上发现一款功能超多的安卓APP,作者宣称是三百多个功能,但是目前统计已经有四百多个,而且不包含网友分享的上千功能。这款工具的名称叫:宇宙工具箱。它的功能主要包......
  • 微信小程序的全局弹窗以及全局实例
    全局组件微信小程序组件关系中,父组件使用子组件需要在父组件index.json中引入子组件,然后在父组件页面中使用,这种组件的对应状态是一对一的,一个组件对应一个页面。如果有一......