我想使用Electron,nuxt.js和am4charts编写桌面应用程序的代码。用
导入am4charts核心时 import * as am4core from '@amcharts/amcharts4/core'
应用返回错误:
export { System, system } from "./.internal/core/System";
^^^^^^
SyntaxError: Unexpected token export
我的设置:
我已经尝试使用以下命令在nuxt.config.js中转载amCharts
build: {
transpile: [
'@amcharts/amcharts4'
],
vendor: ['v-tooltip']
}
但没有成功。我该如何解决这个问题?
答案 0 :(得分:2)
我发现它是nuxt.js和amcharts.js之间的已知问题,它的解决方案如下:
创建文件plugins / amcharts.js
import * as am4core from "@amcharts/amcharts4/core";
import * as am4charts from "@amcharts/amcharts4/charts";
import am4themes_animated from "@amcharts/amcharts4/themes/animated";
import am4themes_dark from "@amcharts/amcharts4/themes/dark";
import Vue from "vue";
Vue.prototype.$am4core = () => {
return {
am4core,
am4charts,
am4themes_animated,
am4themes_dark
}
}
然后添加到nuxt.config.js
plugins: [
{
src: '~/plugins/amCharts.js',
ssr: false
}
],
在组件文件中
mounted() {
let {am4core, am4charts, am4themes_animated, am4themes_dark} = this.$am4core();
}
在Github上找到了解决方案:https://github.com/nuxt/nuxt.js/issues/3336