Include jQuery into Symfony2

前端 未结 4 686
情歌与酒
情歌与酒 2020-12-03 06:20

I am new in Symfony2 framework and not fully understand how to work with javascripts and how to include theirs in the best way.

What I need: to include jQuery script

4条回答
  •  执笔经年
    2020-12-03 07:08

    Assuming your jquery.min.js is placed under src/Acme/FooBundle/Resources/public/js/

    You can use either

    
    

    or

    {% javascripts
        '@AcmeFooBundle/Resources/public/js/jquery.min.js'
    %}
        
    {% endjavascripts %}
    

    Into your twig template.

    Make sure you installed the assets afterwards or run this command

    php app/console assets:install web --symlink
    

提交回复
热议问题