首页 > 解决方案 > 尝试导入 amCharts 模块时出现语法错误

问题描述

我正在尝试通过 npm 使用 amcharts,我在其中运行命令 npm install@amcharts/amcharts4 我可以看到,现在在我的节点模块和 package.json 中,我拥有与 amcharts 关联的所有模块,还有我的包。 json 已更新,现在包含这一行“@amcharts/amcharts4”:“^4.10.22”,我创建了两个文件 index.html 和 chart.js。在我的 app.js 的顶部,我添加了以下几行

import * as am4core from "@amcharts/amcharts4/core";
import * as am4charts from "@amcharts/amcharts4/charts";
import am4themes_animated from "@amcharts/amcharts4/themes/animated"; 

当我尝试使用以下脚本将我的 charts.hs 包含在我的 index.html 中时

<script src="charts.js"></script>

我一直收到相同的语法错误,但我仍然找不到解决方法“未捕获的语法错误:无法在模块外使用 import 语句”有人知道我做错了什么吗?提前致谢

标签: javascriptnpmnode-modulesamcharts

解决方案


推荐阅读