gpt4 book ai didi

javascript - Chart.js 无法在 Heroku 上正确部署

转载 作者:行者123 更新时间:2023-12-03 08:29:58 24 4
gpt4 key购买 nike

我一直在本地应用程序中使用 angular-chart.js,并且没有遇到问题。但是,当我在 Heroku 上部署应用程序时,我的页面中断,因为 Chart.js 未正确部署。

Uncaught SyntaxError: Unexpected token < Chart.min.js:1

Uncaught ReferenceError: Chart is not defined angular-chart.min.js:1

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.6/$injector/modulerr?p0=swellsApp&p1=Error%…swells.herokuapp.com%2Fassets%2Flibs%2Fangular%2Fangular.min.js%3A19%3A463) angular.min.js:38

当我在本地服务器上运行它时,我没有收到这些错误。我正在正确地获取脚本,并将我的依赖项也包含在我的应用程序中。我不明白的是我的其他脚本加载没有问题。只是 Chart.js 给了我这个问题......

有什么想法吗???

我在 Chrome 开发工具的资源下看到的内容

enter image description here

index.html

 <head>
<meta charset="utf-8">
<title>Swells</title>
<!-- For Angular Routing -->
<base href="/">
<!-- CSS -->
<link rel="stylesheet" href="public/assets/libs/normalize-css/normalize.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/darkly/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.min.css">
<link rel="stylesheet" href="assets/libs/angular-chart.js/dist/angular-chart.min.css">
<link rel="stylesheet" href="../../assets/css/style.css">

<!-- JAVASCRIPT LIBS -->
<script src="assets/libs/angular/angular.min.js"></script>
<script src="assets/libs/angular-route/angular-route.min.js"></script>
<script src="assets/libs/angular-animate/angular-animate.min.js"></script>
<script src="assets/libs/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
<script src="assets/libs/angular-messages/angular-messages.min.js"></script>
<script src="assets/libs/Chart.js/Chart.min.js"></script>
<script src="assets/libs/angular-chart.js/dist/angular-chart.min.js"></script>

<!-- MAP API -->
<script src="https://maps.googleapis.com/maps/api/js"></script>

<!-- Controllers -->
<script src="app/controllers/mainCtrl.js"></script>
<script src="app/controllers/userCtrl.js"></script>
<script src="app/controllers/mapCtrl.js"></script>
<script src="app/controllers/surfCtrl.js"></script>
<script src="app/controllers/weatherCtrl.js"></script>
<script src="app/controllers/surfReportCtrl.js"></script>

<!-- Services -->
<script src="app/services/authService.js"></script>
<script src="app/services/userService.js"></script>
<script src="app/services/surfService.js"></script>
<script src="app/services/weatherService.js"></script>
<script src="app/services/surfReportService.js"></script>


<!-- Main Angular Files -->
<script src="app/routes.js"></script>
<script src="app/app.js"></script>

<!-- SET VEIWPORT FOR MOBILE -->
<meta name="viewport" content="width=device-width, intitial-scale=1.0">
</head>

app.js

angular.module('swellsApp', [
'appRoutes',
'authService',
'userService',
'surfService',
'weatherService',
'surfReportService',
'mainCtrl',
'userCtrl',
'surfCtrl',
'mapCtrl',
'surfReportCtrl',
'weatherCtrl',
'ngMessages',
'ngAnimate',
'ui.bootstrap',
'chart.js'
])
//application configuration to integrate tokens into our requests
.config(function($httpProvider){
//attach auth interceptor to the http requests
$httpProvider.interceptors.push('AuthInterceptor');
});

最佳答案

我找到了这个问题的替代解决方案。我为 Chart.js 采购了一个 CDN,效果很好。由于某种原因,Chart.js 似乎与我的应用程序一起部署,因此我决定从 CDN 获取它,这就成功了

 <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>

关于javascript - Chart.js 无法在 Heroku 上正确部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33380835/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com