我有一个错误,
Attempted import error: 'LeafletProvider' is not exported from 'react-leaflet'.当我尝试将LeafletProvider导入到我的一个组件文件时,如下所示:
import { withLeaflet, MapControl, LeafletProvider } from "react-leaflet";我相信我已经安装了最新版本的react-leaflet (v.3.2.2),并且已经尽可能多地阅读了文档,但我没有在其中看到LeafletProvider。
希望有人能帮我弄清楚该怎么做。基本上,我只是想能够在两个或更多的传单地图平铺层之间切换。
发布于 2021-10-20 06:15:29
看起来提供者必须像这样导入:
import { LeafletContext } from '@react-leaflet/core';并用作:
<LeafletContext.Provider>根据文档的这一页:
发布于 2021-10-20 06:49:55
根据@Ivo答案中的文档,我做了以下操作:
第一次安装:
npm install @react-leaflet/core然后像这样导入:
import { LeafletContext } from "@react-leaflet/core"然后将其用作:
<LeafletContext.Provider>
// enter code here
</LeafletContext.Provider>https://stackoverflow.com/questions/69641087
复制相似问题