javascript - 尝试导入 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 语句”有人知道我做错了什么吗?提前致谢
解决方案
推荐阅读
- r - 在 for 循环中重新编码几个变量
- python-3.x - Pandas 优化了值的查找
- php - 如何在国家下拉列表中显示选定的值
- extjs - 应用程序崩溃:Java 运行时环境检测到致命错误:[libsystem_platform.dylib+0x15d2] _platform_strlen+0x12
- java - Corretto 11 上的 AWS Elastic Beanstalk Tomcat 8.5 无法连接到 AWS 服务
- visual-studio - 如何为 WinForms 桌面应用程序的 URL 安装托管 MSIX 包
- python - XML 属性值无法匹配我的另一个字典的键,因此我无法替换属性值
- php - 是什么 || 符号在 Preg_replace() PHP 中的意思
- reactjs - React Formik Mui TextField 与自定义输入失去焦点
- servicestack - Servicestack orm lite 不会反序列化嵌套的 json 结构