簡體   English   中英

無法在layout.ejs(sails.js)中添加腳本

[英]Not able to add scripts in layout.ejs (sails.js)

我想在layout.ejs中添加一個route.js文件。

<!DOCTYPE html>
<html ng-app="scratchpad">
  <head>
    <title>Scratchpad</title>

    <!-- Viewport mobile tag for sensible mobile support -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">


    <!--
        Stylesheets and Preprocessors
        ==============================

        You can always bring in CSS files manually with `<link>` tags, or asynchronously
        using a solution like AMD (RequireJS).  Or, if you like, you can take advantage
        of Sails' conventional asset pipeline (boilerplate Gruntfile).

        By default, stylesheets from your `assets/styles` folder are included
        here automatically (between STYLES and STYLES END). Both CSS (.css) and LESS (.less)
        are supported. In production, your styles will be minified and concatenated into
        a single file.

        To customize any part of the built-in behavior, just edit `tasks/pipeline.js`.
        For example, here are a few things you could do:

            + Change the order of your CSS files
            + Import stylesheets from other directories
            + Use a different or additional preprocessor, like SASS, SCSS or Stylus
    -->
    <!--Twitter Bootstrap-->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
    <!--Twitter Bootstrap END-->
    <!--STYLES-->
    <link rel="stylesheet" href="/styles/border.css">
    <link rel="stylesheet" href="/styles/tablerow.css">
    <!--STYLES END-->
  </head>

  <body>
    <nav class = "navbar navbar-default" role = "navigation">
      <div class = "container-fluid">
        <div class = "navbar-header">
          <a class = "navbar-brand" ui-sref = "scratchpad">MY SCRATCHPAD</a>
        </div>
      </div>

    </nav>


    <p>hello world</p>

    <div class = "container">
      <div ui-view></div>
    </div>

    <!--SCRIPTS-->
    <script src="/js/dependencies/sails.io.js"></script>
    <script src="/js/dependencies/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="/js/dependencies/bower_components/angular/angular.min.js"></script>
    <script src="/js/dependencies/bower_components/angular-resource/angular-resource.min.js"></script>
    <script src="/js/dependencies/bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
    <script src="/js/dependencies/bower_components/moment/moment.js"></script>
    <script src="/js/dependencies/application.js"></script>
    <script src="/js/dependencies/route.js"></script>

    <!--SCRIPTS END-->
  </body>
</html>

每當我添加它並保存它。 它得救了。 但是,當我嘗試運行sails lift route.js腳本消失了,layout.ejs文件變為舊狀態。 有人能搞清楚嗎? 什么可能是錯誤的想法? 咕嚕聲的原因?

只要我記得,里面的一切

 <!--SCRIPTS-->
...

<!--SCRIPTS END-->

section由sails生成。 嘗試將鏈接放在后面,這樣就好了

<!--SCRIPTS-->
<script src="/js/dependencies/sails.io.js"></script>
<script src="/js/dependencies/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/js/dependencies/bower_components/angular/angular.min.js"></script>
<script src="/js/dependencies/bower_components/angular-resource/angular-resource.min.js"></script>
<script src="/js/dependencies/bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
<script src="/js/dependencies/bower_components/moment/moment.js"></script>
<script src="/js/dependencies/application.js"></script>   
<!--SCRIPTS END-->
<script src="/js/dependencies/route.js"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM