【问题标题】:Chart.js not working after Django deployment on Heroku在 Heroku 上部署 Django 后 Chart.js 无法正常工作
【发布时间】:2021-01-14 07:17:08
【问题描述】:

我的 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.

【问题讨论】:

    标签: django heroku chart.js momentjs


    【解决方案1】:

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

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

    【讨论】:

    • 我对网站和 chart.js 还很陌生,我该怎么做?
    • 看起来您在某个地方使用链接加载了图书馆时刻,如果您用我的答案中的链接替换该链接,它应该可以工作
    • 我遇到了同样的错误The page at 'https:/../' 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.
    • 你能分享你的代码吗,因为它仍然试图通过 http 加载它
    • 我应该分享哪一部分?加载这些脚本的标签?
    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 2013-02-20
    • 2019-07-25
    • 1970-01-01
    • 2023-03-23
    • 2021-10-24
    • 2021-03-25
    • 1970-01-01
    相关资源
    最近更新 更多