首页 > 解决方案 > 在 Heroku 上部署 Django 后 Chart.js 无法正常工作

问题描述

我的 Django 网站运行良好,localhost:8000但是当我上传到 Heroku 时,图表不再显示。有什么典型的原因吗?我在控制台中收到的错误Uncaught Error: Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.comThe page at 'https://...com/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js'. This request has been blocked; the content must be served over HTTPS.

标签: djangoherokuchart.jsmomentjs

解决方案


错误说明了一切。您尝试通过 http 加载即时脚本,但由于这是一个不安全的协议,oit 已被阻止,您必须通过 https 加载脚本。

https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js


推荐阅读