theClown
theClown
  • 发布:2020-08-17 17:14
  • 更新:2022-08-27 18:52
  • 阅读:776

HBuilderX2.8.6 版本nvue uni.createMapContext("mapid", this);【报Bug】

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: windows 10(企业版)

HBuilderX类型: 正式

HBuilderX版本号: 2.8.6

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: p30 pro

页面类型: nvue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<map id="indexMap" key='indexmap'  ref="indexmap" :style="{width: '750rpx', height: windowHeight + 'px'}" show-location :polyline="routesLocations" :markers='markers'></map>
onLoad() {  
    map = uni.createMapContext("indexmap", this); //初始化地图组件  
}

操作步骤:

nvue 页面

预期结果:

成功创建map 实例

实际结果:

看图 , Can not find indexmap

bug描述:

非首页的情况, nvue 页面 在 onLoad 里创建地图对象 报错,在vue 页面正常,错误不仅限于华为手机, 试过多种机型 及模拟器都是报错的

2020-08-17 17:14 负责人:无 分享
已邀请:
theClown

theClown (作者)

声明 组件 上述代码中 indexMap,实际代码中为indexmap,大小写都测试过,与组件id大小写无关

  • 9***@qq.com

    解决没啊 我也是报这个错,而且不能用mapContext这里面的方法

    2020-08-27 16:34

x***@163.com

x***@163.com - D_and_D

原因是uni.createMapContext("indexmap", this) 里面的第一个参数,必须和map组件里面的 id 对应,没有id会报这个错

w***@hebeihengzun.com

w***@hebeihengzun.com

uni.createMapContext("indexmap", this) 是没问题的 但是在调用点对象没有初始化成功 可能是异步没有走完

要回复问题请先登录注册