我如何将传单螺旋式Ecorator与VUE应用程序一起使用

发布于 2025-02-12 07:53:34 字数 1366 浏览 0 评论 0 原文

我有一个vue 2示例项目,位于 https://github.com/ericg-vue-vue-vue-com-问题/传单测试

这是我代码我不确定我不确定如何处理。

我尝试过的几件事是修改代码做:

<script>
import "leaflet/dist/leaflet.css";
import L from "leaflet";
import * from 'leaflet-polylinedecorator';

但是这导致构建错误:

  10:9  error  Parsing error: Unexpected token, expected "as"
> 4 | import * from 'leaflet-polylinedecorator';

index.html ,我也尝试添加:

<script src="../node_modules/leaflet-polylinedecorator/dist/leaflet.polylineDecorator.js"></script>

但这导致运行时错误:

Uncaught SyntaxError: Unexpected token '<' (at leaflet.polylineDecorator.js:1:1)

需要更改什么,以便我可以使用VUE应用程序导入并使用此传单扩展名?

I have a Vue 2 sample project at https://github.com/ericg-vue-questions/leaflet-test

This is a simple import issue for my code that I am not sure how to handle.

A couple of things I have tried are to modify the code to do:

<script>
import "leaflet/dist/leaflet.css";
import L from "leaflet";
import * from 'leaflet-polylinedecorator';

but this results in a build error:

  10:9  error  Parsing error: Unexpected token, expected "as"
> 4 | import * from 'leaflet-polylinedecorator';

To the index.html, I also tried adding:

<script src="../node_modules/leaflet-polylinedecorator/dist/leaflet.polylineDecorator.js"></script>

but that results in the runtime error:

Uncaught SyntaxError: Unexpected token '<' (at leaflet.polylineDecorator.js:1:1)

What needs to be changed so I can import and use this leaflet extension with a vue app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝咒 2025-02-19 07:53:34

我发现的一种解决方案是修改 main.js 因此,看起来:

import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

require( "../node_modules/leaflet-polylinedecorator/dist/leaflet.polylineDecorator.js" );

new Vue({
  render: h => h(App),
}).$mount('#app')

添加需要解决了问题。

如果有的话,我会对替代解决方案感兴趣。

A solution I found was to modify main.js so it looks like:

import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

require( "../node_modules/leaflet-polylinedecorator/dist/leaflet.polylineDecorator.js" );

new Vue({
  render: h => h(App),
}).$mount('#app')

Adding the require resolved the problem.

I would be interested in alternative solutions, if there are any.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文