2017-08-02 33 views
0

我有這個base.html.twig與materialize.ccs塊的JavaScript不工作

<!DOCTYPE html> 
<html lang="en"> 

<!--================================================================================ 
    Item Name: Materialize - Material Design Admin Template 
    Version: 3.1 
    Author: GeeksLabs 
    Author URL: http://www.themeforest.net/user/geekslabs 
================================================================================ --> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="msapplication-tap-highlight" content="no"> 
    <meta name="description" content="Materialize is a Material Design Admin Template,It's modern, responsive and based on Material Design by Google. "> 
    <meta name="keywords" content="materialize, admin template, dashboard template, flat admin template, responsive admin template,"> 
    <title>{% block title %}Login Page | Materialize - Material Design Admin Template{% endblock %}</title> 


    <!-- Favicons--> 
    <link rel="icon" href="images/favicon/favicon-32x32.png" sizes="32x32"> 
    <!-- Favicons--> 
    <link rel="apple-touch-icon-precomposed" href="images/favicon/apple-touch-icon-152x152.png"> 
    <!-- For iPhone --> 
    <meta name="msapplication-TileColor" content="#00bcd4"> 
    <meta name="msapplication-TileImage" content="images/favicon/mstile-144x144.png"> 
    <!-- For Windows Phone --> 

{% block stylesheets %} 
    <!-- CORE CSS--> 

    <link href="{{asset('css/materialize.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 
    <link href="{{asset('css/style.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 
    <!-- Custome CSS-->  
    <link href="{{asset('css/custom/custom.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 
    <link href="{{asset('css/layouts/page-center.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 

    <!-- INCLUDED PLUGIN CSS ON THIS PAGE --> 
    <link href="{{asset('js/plugins/prism/prism.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 
    <link href="{{asset('js/plugins/perfect-scrollbar/perfect-scrollbar.css')}}" type="text/css" rel="stylesheet" media="screen,projection"> 

    {% endblock %} 

</head> 

<body class="cyan"> 
{% block body %} 

{% endblock %} 

{% block javascript %} 
    <!-- ================================================ 
    Scripts 
    ================================================ --> 

    <!-- jQuery Library --> 
    <script type="text/javascript" src="{{asset('js/plugins/jquery-1.11.2.min.js')}}"></script> 
    <!--materialize js--> 
    <script type="text/javascript" src="{{asset('js/materialize.js')}}"></script> 
    <!--prism--> 
    <script type="text/javascript" src="{{asset('js/plugins/prism/prism.js')}}"></script> 
    <!--scrollbar--> 
    <script type="text/javascript" src="{{asset('js/plugins/perfect-scrollbar/perfect-scrollbar.min.js')}}"></script> 

     <!--plugins.js - Some Specific JS codes for Plugin Settings--> 
    <script type="text/javascript" src="{{asset('js/plugins.js')}}"></script> 
    <!--custom-script.js - Add your own theme custom JS--> 
    <script type="text/javascript" src="{{asset('js/custom-script.js')}}"></script> 

    <script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script> 
    <script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script> 


{% endblock %} 
</body> 

</html> 

如果我在另一個文件中儘量延長它的JavaScript不工作

{% extends 'base.html.twig' %} 

{% block body %} 


{% endblock %} 

{% block javascripts %} 

     {{parent()}} 
     <script src="{{ asset('js/xxxxx.js') }}"></script> 

{% endblock %} 

這塊是看不到.. 我在其他項目中使用這個與其他模板,它的工作... 控制檯瀏覽器沒有看到任何錯誤,如果我改變(file.js的名稱),所以我認爲是不正確添加到樹枝文件。 可以幫到我嗎?

回答

2

你在你的base.html.twig有一個錯字,你命名你的塊javascript沒有 「S」)

1

使用{%塊的javascript%}在你的第二個文件insted的{%塊的JavaScript%}的