duanfen1992 2014-05-29 10:56
浏览 26
已采纳

树枝中的动态JS路线[重复]

This question already has an answer here:

I want to include different js file, depending on environment. I've tried:

{% javascripts
    'bundles/fosjsrouting/js/router.js'
    'bundles/fosjsrouting/' ~ app.environment ~ '/js/fos_js_routes.js'
    filter='?yui_js'
    output='compiled/routing'
    %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
 {% endjavascripts %}

But it gives error about unexpected character ~. Any suggestions?

</div>
  • 写回答

1条回答 默认 最新

  • doubu4406 2014-05-29 11:00
    关注

    That isn't possible unfortunately at the moment. This is because you can't use variables in Assetic paths.

    However, you could use asset twig helper:

    <script src="{{ asset('bundles/fosjsrouting/' ~ app.environment ~ '/js/fos_js_routes.js') }}"></script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 openwrt双栈NAT
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用