首页 > 解决方案 > 如何在带有 Proyect Symfony 的 vueJS 中使用路径树枝 - 如何正确使用 FSRouting

问题描述

我有一个Vue代码,但我需要显示一个链接twig

<template>
<div class="col t-blk text-center d-flex justify-content-around">                                                       
<a class="btn btn-primary btn-md border-r-0 d-table py-2 px-4" href="{{path('corpasesoria')}}">Con Asesor</a>
<a class="btn btn-primary btn-md border-r-0 d-table py-2 px-4" id="step01-tab" data-toggle="tab" href="#step01" role="tab" aria-controls="step01" aria-selected="false">Sin Asesor</a>
</div>
</template>

但是在编译webpack的时候,twig的链接显示错误,无法推进。

这是错误:

ERROR  Failed to compile with 1 errors                                                                     00:58:12

 error  in ./assets/components/Corporativo/Corporativo.vue?vue&type=template&id=270a4b6a&scoped=true&

Module Error (from ./node_modules/vue-loader/lib/loaders/templateLoader.js):
(Emitted value instead of an instance of Error) 

  Errors compiling template:

  href="{{path('corpasesoria')}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.

  15 |                                                                                          <div class="row">
  16 |                                                                                                  <div class="col t-blk text-center d-flex justify-content-around">
  17 |                                                                                                          <a class="btn btn-primary btn-md border-r-0 d-table py-2 px-4" href="{{path('corpasesoria')}}">Con Asesor</a>
     |                                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  18 |                                                                                                          <a class="btn btn-primary btn-md border-r-0 d-table py-2 px-4" id="step01-tab" data-toggle="tab" href="#step01" role="tab" aria-controls="step01" aria-selected="false">Sin Asesor</a>
  19 |                                                                           

你有什么主意吗?

标签: symfonywebpackvuejs2twig

解决方案


这是一个例子

import RoutingData from '../../../../dist/js/fos_js_routes';

从'fos-routing'导入路由;

路由.setData(路由数据);导出默认路由;


推荐阅读