我要在主包装模板中导入用于语义的样式表和脚本,因此可以在任何地方使用它,但是由于某种原因,我在子页面上导入的Semantic-UI-Calendar模块无法找到语义元素。它引发错误:Calendar: UI Popup, a required component is not included in this page.
我已经包含了相关文件的head
s。
wrapper.html
<head>
<meta charset="utf-8">
<title>{% block title %}{% endblock %} · {{ config["APP_NAME"] }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='vendor/semantic/dist/semantic.min.css') }}"></link>
<link rel="stylesheet" href="{{ url_for('static', filename='css/branding.css') }}"></link>
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"></link>
{% block head %}
{% endblock %}
</head>
...
register.html
{% extends "wrapper.html" %}
{% from "_formhelpers.html" import render_field %}
{% block head %}
{{ super() }}
<script type="text/javascript" src="{{ url_for("static", filename="bower_components/semantic-ui-calendar/dist/calendar.min.js") }}"></script>
<link rel="stylesheet" href="{{ url_for("static", filename="bower_components/semantic-ui-calendar/dist/calendar.min.css") }}"/>
<style>
#welcome {
text-align: center;
}
</style>
<script>
$("#dob-picker").calendar({
type: "date",
startMode: "year"
})
</script>
{% endblock %}
我的静态文件目录结构目前看起来像这样: ```
static/
|---- bower_components/
|-----|---- semantic-ui-calendar/
|---- node_modules/
|---- css/
|---- fonts/
|---- scripts/
|---- vendor/
|-----|---- semantic/
|-----------|----src/
|-----------|----dist/
... etc.