最经在学flask 一个问题:
在使用
flask-moment
本地化日期和时间时,代码正常,时间日期不显示
详细代码不写了 代码

问题原因:
moment.js
使用的是Cloudflare的CDN,加载失败 导致渲染失败。
从下图看出 moment-with-locales.min.js
加载失败了,可能加载时间超时。cdn解析时间过长。

解决问题:
添加CDN,就是让游览器加载moment.js
时,不需要中介直接找到moment.js
文件。
做法:
在moment.include_moment()
中添加地址参数local_js="https://static.pdflibr.com/momentjs/moment.min.js"
{% block scripts %}
{{ super() }}
{{ moment.include_moment(local_js="https://static.pdflibr.com/momentjs/moment.min.js") }}
{% endblock %}
问题成功解决了

网友评论