你们可以建议我如何在应用程序中添加本地js文件
我试过在index.html
中添加本地JS文件路径,如下所示
<script src="thirdpartyscripts/amcharts.js"></script>
这里**thirdpartyscripts**
是我的目录。
但得到如下错误。
答案 0 :(得分:2)
将此文件夹和文件复制到target / www文件夹中。或者使用webpack在webpack.commons.js中为您执行此操作。看看我添加的最后一行
new CopyWebpackPlugin([
{ from: './node_modules/core-js/client/shim.min.js', to: 'core-js-shim.min.js' },
{ from: './node_modules/swagger-ui/dist', to: 'swagger-ui/dist' },
{ from: './src/main/webapp/swagger-ui/', to: 'swagger-ui' },
{ from: './src/main/webapp/favicon.ico', to: 'favicon.ico' },
{ from: './src/main/webapp/manifest.webapp', to: 'manifest.webapp' },
// { from: './src/main/webapp/sw.js', to: 'sw.js' },
{ from: './src/main/webapp/robots.txt', to: 'robots.txt' },
{ from: './src/main/webapp/thirdparty/sth.js', to: 'thirdparty/sth.js' }
]),