2016-03-08 82 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

相关问题