How to include quot;leaflet.cssquot; in a React app with webpack?(如何包含“leaflet.css在带有 webpack 的 React 应用程序中?)
问题描述
我使用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 应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何包含“leaflet.css"在带有 webpack 的 React 应用程序中?


基础教程推荐
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01