简体   繁体   English

如何在vue中使用twig

[英]how to use twig in vue

i have simple modal window plan.vue with slot我有带插槽的简单模态窗口 plan.vue

            ...
            <div class="plan__content">
                <slot></slot>
            </div>
           ...

there is also example.vue where it is used还有使用它的example.vue

                        <button
                            @click="showPlan"
                        >
                            Show plan
                        </button>
                        <plan
                            v-if="isPlanVisible"
                            @closePlan="closePlan"
                        >
                        </plan>

and i also have twig file plan.html.twig我也有树枝文件 plan.html.twig

{% block field %}
    <table id="plan_table">
      <caption>
        <h2> {{smth.name}} </h2>
      </caption>
    ...
    </table>

{% endblock %}

can i add my twig here <plan> </plan> somehow?我可以在这里添加我的树枝<plan> </plan>以某种方式吗? I tried to find a solution but only found how to add vue to twig and not vice versa我试图找到一个解决方案,但只找到了如何将 vue 添加到 twig 而不是反之亦然

You can not embed a twig file inside a Vue component and render it.您不能在 Vue 组件中嵌入 twig 文件并渲染它。 You have two alternative options:您有两种选择:

  1. You implement you twig template in "Vue Code" and don't use the twig template at all.您在“Vue 代码”中实现了树枝模板,并且根本不使用树枝模板。
  2. You load the rendered twig template via HTTP Request from a backend endpoint and render the response inside you Vue component vie v-html attribute for example.例如,您通过来自后端端点的 HTTP 请求加载呈现的树枝模板,并在 Vue 组件 vie v-html 属性中呈现响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM