Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro 3.0.2 中 <Map>组件的属性参数 setting 为可选,但事实是如果不设置 setting,微信调试工具报错:Cannot read property 'layerStyle' of null #6949

Closed
puxiao opened this issue Jul 7, 2020 · 1 comment · Fixed by #7101
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Milestone

Comments

@puxiao
Copy link

puxiao commented Jul 7, 2020

相关平台

微信小程序

小程序基础库: 2.11.3
使用框架: React

复现步骤

新建一个页面,使用 <Map />组件,根据Taro代码提示,给Map组件添加必要的 经纬度 属性值,例如:

<Map longitude={116.38} latitude={39.90} />

此时页面不报错,编译正常,但是在微信调试工具里访问该页面,则会报错误:Cannot read property 'layerStyle' of null


解决方式:给Map 组件添加一个 setting的值,哪怕是一个空对象({})也可以,将上面代码修改为:

<Map longitude={116.38} latitude={39.90} setting={{}} />

修改之后再编译,微信调试则地图不报错误。

期望结果

期望正常展现地图。

实际结果

报以下错误:
TypeError: Cannot read property 'layerStyle' of null
at i._insertIframeMap (:11120/pageframe/dev/WAWebview.js:2)
at window.__map_jssdk_init (:11120/pageframe/dev/WAWebview.js:2)
at eval (eval at (mapapi.qq.com/jsapi_v2/2/4/132/main.js:1), :1:21)
at mapapi.qq.com/jsapi_v2/2/4/132/main.js:1

SystemError (webviewScriptError)
Cannot read property 'layerStyle' of null
TypeError: Cannot read property 'layerStyle' of null
at i._insertIframeMap (http://127.0.0.1:11120/__pageframe__/__dev__/WAWebview.js:2:1124471)
at window.__map_jssdk_init (http://127.0.0.1:11120/__pageframe__/__dev__/WAWebview.js:2:1121728)
at eval (eval at (https://mapapi.qq.com/jsapi_v2/2/4/132/main.js:1:61434), :1:21)
at https://mapapi.qq.com/jsapi_v2/2/4/132/main.js:1:61434

Uncaught

环境信息

  Taro CLI 3.0.2 environment info:
    System:
      OS: Windows 7
    Binaries:
      Node: 12.13.0 - D:\Program Files\nodejs\node.EXE
      npm: 6.14.2 - D:\Program Files\nodejs\npm.CMD

补充信息

希望能够修改 @tarojs/components/types/Map.d.ts 中 onTap,将 setting 改为必需项,以获得TS的语法检查。
或者给 Map 组件默认加上 setting 属性,不用再手工添加。

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jul 7, 2020
@Chen-jj Chen-jj added this to the 3.0.6 milestone Jul 17, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 17, 2020

下个版本会加上默认值 []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants