我使用survivorjs.com 网站作为模板,使用webpack 构建基于地图的React 应用程序.对于我使用传单的地图,但我找不到添加leaflet.css 的方法.如果没有这个,地图图块的显示顺序就会错误.
I using the survivejs.com site as a template to build a map based React app with webpack. For the map i am using leaflet but i can't find a way to add the leaflet.css. Without this the map tiles are displayed in the wrong order.
我尝试使用这个将leaflet.css 添加到App.jsx 文件中
I have tried adding the leaflet.css to the App.jsx file using this
require('leaflet/dist/leaflet.css');
但出现以下错误
ERROR in ./~/leaflet/dist/leaflet.css
Module parse failed: myApp/node_modules/leaflet/dist/leaflet.css Unexpected token (3:0)
You may need an appropriate loader to handle this file type.
如果我可以访问 index.html,我可以将它添加到那里,但我使用 webpack,我不清楚如何做到这一点?
If I had access to the index.html i could add it there but i with webpack, i'm unclear how to do this?
我通过像这样简单地导入 CSS 来解决它:
I solved it by simply importing the CSS like this:
import 'leaflet/dist/leaflet.css';
这篇关于如何包含“leaflet.css"在带有 webpack 的 React 应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
react-leaflet 创建自定义组件react-leaflet create a custom components(react-leaflet 创建自定义组件)
如何在 Leaflet 中显示超出特定缩放级别的标签?How do I show a label beyond a certain zoom level in Leaflet?(如何在 Leaflet 中显示超出特定缩放级别的标签?)
为传单中的标记分配 IDAssign ID to marker in leaflet(为传单中的标记分配 ID)
Leaflet _ ReactJS - 在哪里可以找到 invalidateSize 属性Leaflet _ ReactJS - Where to find the invalidateSize property?(Leaflet _ ReactJS - 在哪里可以找到 invalidateSize 属性?)