我可以找到两种方法来显示选项卡:1.使用Ajax并嵌入HTML 2.通过继承子布局中的布局使用页面加载
1.使用Ajax(我正在使用JQuery Ajax)
// Python@app.route('/get-tab/<int:id>')def get_tab(id): return render_template('tab-template.html')// View {% extends 'layout/base.html' %} {% block content %} <button onclick="loadPage(1)">First</button> <button onclick="loadPage(2)">Second</button> <div id="display"></div> <script> function loadPage(id) { $.ajax({ type: 'GET', url: '/get-tab/' + id, success: function (e) { $('#display').html(e); } }); } </script> {% endblock %}演示:http://phearaeun.pythonanywhere.com/child
2.继承基础布局到子布局
--> base Layout --> Child layout --> Template// base Layout...{% block content %}{% endblock %}...// Child layout to inherit base layout...{% extends 'layout/base.html' %}{% block content %} // Header content {% block subcontent %}{% endblock %}{% endblock %}...// Template to inherit child layout...{% extends 'layout/child.html' %}{% block subcontent %}{% endblock %}


