duanliao3826 2015-05-05 07:11
浏览 39
已采纳

javascript如何在Symfony2中运行

I am trying to understand how do you use jquery or other scripts in Symfony2. I read the Assets documentation, however that didnt help me that much.

So I have a base.html.twig file in which I add the jquery library and my script file that contains a simple script.

I add it like this:

{% block javascripts %}
    {# Le Javascript #}         
    {% javascripts 
        'bundles/mpFrontend/assets/js/jquery-1.11.2.min.js'         
        'Mp/ShopBundle/Resources/js/scripts.js'   
    %}
        <script src="{{ asset_url }}"></script>       
    {% endjavascripts %}

Now I have a index.html.twig in which I extend the base.html.twig.... Is that all I need? For me the script doesn’t work, do I need to somehow access it in index.html.twig too?

  • 写回答

1条回答 默认 最新

  • doulao2128 2015-05-05 07:32
    关注

    You are messed up with Asstic library and Assets commponent. It is not the same. You should use command:

    php app/console assetic:dump
    

    This command will compile your js file and will put it in right place.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题