【发布时间】:2018-07-06 08:26:37
【问题描述】:
我希望能够在 Vue 组件的模板中定义块,如下所示:
{# templates/blog/layout.html.twig #}
{% extends 'base.html.twig' %}
{% block body %}
<h1>Blog Application</h1>
{% block content %}{% endblock %}
{% endblock %}
然后在不同的组件中使用上面的模板,例如:
{# templates/blog/index.html.twig #}
{% extends 'blog/layout.html.twig' %}
{% block content %}
{% for entry in blog_entries %}
<h2>{{ entry.title }}</h2>
<p>{{ entry.body }}</p>
{% endfor %}
{% endblock %}
示例来自:https://symfony.com/doc/current/templating/inheritance.html
这可能吗?我已经在使用扩展 API (https://vuejs.org/v2/api/#Vue-extend),但无法覆盖特定块。
谢谢:)
【问题讨论】:
标签: inheritance vue.js vue-component