我正在尝试安装FOSJsRoutingBundle。我按照文档here进行了操作。但出于某种原因,我得到了这个错误:
编译错误:已定义标签'not_fos_js_routing_js'
var \ cache \ dev \ FooUrlMatcherGenerator.php中的堆栈跟踪
> return $this->mergeDefaults(array_replace($matches, array('_route' => 'fos_js_routing_js', '_site' => '2')), array (
> '_controller' => 'fos_js_routing.controller:indexAction', '_format'
> => 'js',));
> }
> not_fos_js_routing_js:
我以多种方式清除了所有缓存(手动和命令)。我安装了资产......等但结果仍然相同。 生根
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
布局(javascript块)
{% javascripts '@fooBundle/Resources/public/js/jquery-3.2.1.min.js'
'@fooBundle/Resources/public/js/bootstrap.min.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' })
我的javascript脚本使用它:
var url= Routing.generate('foo_rout_that_exsists', { id: 3 }, true);
alert(url);
答案 0 :(得分:1)
config.yml
fos_js_routing:
routes_to_expose: [ "[a-zA-z0-9_-]+" ]
您还可以参考FOSJsRoutingBundle
的symfony官方文档