小程序开发工具中重绘页面会导致map报错?
发布于 6 年前 作者 tzhou 12088 次浏览 来自 官方Issues

如题,重绘页面时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](/user/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;

1 回复

你好,是使用了其他的框架吗?请移步对应的社区进行提交issue。

回到顶部