2016-03-08 78 views
0

我使用的樹枝作爲我的模板,利用佈局,在其中我有一個JavaScript塊爲什麼我的javascript文件不能在資產中找到?

... 
    {% block javascripts %} 
     {% javascripts 
      '@jquery' 
      '@bootstrap_js' %} 
     <script src="{{ asset_url }}"></script> 
     {% endjavascripts %} 
    {% endblock %} 


</body> 

在內容模板,我有

{% block javascripts %} 
    {{ parent() }} 
    {% javascripts '@AppBundle/Resources/public/index/*' %} 
    <script src="{{ asset_url }}"></script> 
    {% endjavascripts %} 
{% endblock %} 

這是我的配置的assetic節.yml

assetic: 
debug:   true 
use_controller: false 
filters: 
    cssrewrite: ~ 
assets: 
    bootstrap_js: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/js/bootstrap.min.js 
    bootstrap_css: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap.css 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/css/bootstrap-theme.css 
     filters: 
      [cssrewrite] 
    bootstrap_glyphicons_ttf: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf 
     output: 
      "../fonts/glyphicons-halflings-regular.ttf" 
    bootstrap_glyphicons_eot: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.eot 
     output: 
      "../fonts/glyphicons-halflings-regular.eot" 
    bootstrap_glyphicons_svg: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.svg 
     output: 
      "../fonts/glyphicons-halflings-regular.svg" 
    bootstrap_glyphicons_woff: 
     inputs: 
      - %kernel.root_dir%/../vendor/twbs/bootstrap/dist/fonts/glyphicons-halflings-regular.woff 
     output: 
      "../fonts/glyphicons-halflings-regular.woff" 
    jquery: 
     inputs: 
      - %kernel.root_dir%/../vendor/components/jquery/jquery.min.js 

其他一切正常,除了在@AppBundle/Resources/public/index/*下的文件。我跑assetic:dump我的環境,一切順利,但我不斷收到404 HTML轉儲腳本元素下的@AppBundle/Resources/public/index/*

<script src="/logbook/web/js/431d650.js"> 
    <!DOCTYPE html> 
<html> 
<head> 
    <meta charset="UTF-8" /> 
    <title>An Error Occurred: Not Found</title> 
</head> 
<body> 
    <h1>Oops! An Error Occurred</h1> 
    <h2>The server returned a "404 Not Found".</h2> 

    <div> 
     Something is broken. Please let us know what you were doing when this error occurred. 
     We will fix it as soon as possible. Sorry for any inconvenience caused. 
    </div> 
</body> 
</html> 
</script> 

東西壞了,很明顯,但我想不出什麼???

回答

0

過去我也有過使用資產的一些問題,並且寫下了我如何得到它的方法。也許這將幫助你,如果你想嘗試第一次傾倒assetic東西之前執行以下命令:

php app/console assets:install --symlink web 
+0

我跑了,並切斷電源,並且它所作的只是創建網頁內的符號鏈接/捆綁目錄'@的appbundle /資源/公共/指數/ *'。不幸的是,我仍然得到該目錄下的文件的404錯誤。 – cj5

+1

它會工作,如果你想嘗試引用一個特定的文件,例如:{%javascripts'bundles/app/js/jquery-1.11.1.min.js'%} – barbieswimcrew

+0

編號相同的結果。我覺得只是路徑引用不匹配。出於某種原因,只有作曲家目錄中的東西才起作用。 – cj5

相關問題