收藏
回答

小程序开发工具中重绘页面会导致map报错?

如题,重绘页面时map组件会报错

[渲染层错误] TypeError: Cannot read property 'lat' of undefined
    at t.value (https://map.qq.com/api/gljs?v=1.exp&key=6GUBZ-WOJKX-J7H46-7WVQI-E7A66-UTB4X&callback=__map_jssdk_init:11:41039)
    at t.value (https://map.qq.com/api/gljs?v=1.exp&key=6GUBZ-WOJKX-J7H46-7WVQI-E7A66-UTB4X&callback=__map_jssdk_init:11:40708)
    at e.value (https://map.qq.com/api/gljs?v=1.exp&key=6GUBZ-WOJKX-J7H46-7WVQI-E7A66-UTB4X&callback=__map_jssdk_init:11:183839)
    at n.pointsChanged (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:1208393)
    at Function.i.safeCallback (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:209387)
    at n.<anonymous> (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:247609)
    at a.doUpdates (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:264466)
    at e (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:1769925)
    at s (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:1772973)
    at p (http://127.0.0.1:29812/__pageframe__/__dev__/WAWebview.js?t=wechat&s=1612669112128&v=2.15.0:2:1720665)

真机上好像没有这个问题。可以使用以下代码复现问题(通过Taro CLI初始化一个项目,拷贝以下代码到page/index/index.tsx,启动后点击"ceshi")

import React, { useState } from "react";
import { View, Text, Map } from "@tarojs/components";
import "./index.scss";


const Index: React.FC<{}> = ({}) => {
  const [test, setTest] = useState(false);


  return (
    <View className="index">
      <Map longitude={115.225173} latitude={23.213408} />
      {test && <Text>asd</Text>}
      <View
        onClick={() => {
          setTest(true);
          console.log("clicked");
        }}
      >
        ceshi
      </View>
    </View>
  );
};


export default Index;




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

2 个回答

  • 倾她国做她王
    倾她国做她王
    2022-06-08

    我也遇到相同问题,求解

    2022-06-08
    有用
    回复
  • 2021-06-09

    同样遇到这个问题,环境如下:

    env: macOS,mp,1.05.2106092; lib: 2.17.0

    2021-06-09
    有用
    回复
登录 后发表内容
问题标签