[英]Sails.js Assets Not Found
我正在創建一個sails.js 應用程序。 我遇到了一個問題,資產文件夾中包含的每個文件似乎都不起作用。 例如,我在 assets 文件夾中創建了一個 testing123.js 文件,它只向控制台記錄一條簡單的消息。 但該消息永遠不會被記錄。 我有另一個文件應該為 Jquery Validation 設置規則。 但是我的登錄表單上的驗證不起作用。 CSS 樣式似乎也不起作用。 當我在 Chrome 中檢查並導航到 Sources 選項卡時,我查看了這些文件只是為了仔細檢查發生了什么。 令我驚訝的是,我發現 Asset 文件夾中的每個文件顯然都具有相同的內容。 這些內容如下:
<!DOCTYPE html>
<html>
<head>
<title>Login</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
-->
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS: Materialize -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
<!--STYLES-->
<link rel="stylesheet" href="/styles/importer.css">
<link rel="stylesheet" href="/styles/style.css">
<!--STYLES END-->
<!--
Client-side Javascript
========================
You can always bring in JS files manually with `script` tags, or asynchronously
on the client using a solution like AMD (RequireJS). Or, if you like, you can
take advantage of Sails' conventional asset pipeline (boilerplate Gruntfile).
By default, files in your `assets/js` folder are included here
automatically (between SCRIPTS and SCRIPTS END). Both JavaScript (.js) and
CoffeeScript (.coffee) are supported. In production, your scripts 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 scripts
+ Import scripts from other directories
+ Use a different preprocessor, like TypeScript
-->
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!-- Compiled and minified JavaScript: Materialize -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/js/materialize.min.js"></script>
<!-- Compiled and minified JavaScript: JQuery Form Validation -->
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<!--SCRIPTS-->
<script src="/js/dependencies/sails.io.js"></script>
<script src="/js/script.js"></script>
<!--SCRIPTS END-->
</head>
<body>
<div class="section"></div>
<main>
<center>
<div class="section"></div>
<h5 class="indigo-text">Please, login into your account</h5>
<div class="section"></div>
<div class="container">
<div class="z-depth-1 grey lighten-4 row" style="display: inline-block; padding: 32px 48px 0px 48px; border: 1px solid #EEE;">
<form id="loginForm" class="col s12" method="POST" action="/CMD_User/login">
<div class='row'>
<div class='col s12'>
</div>
</div>
<div class='row'>
<div class='input-field col s12'>
<input class='validate' type='email' name='email' id='email'/>
<label for='email'>Enter your email</label>
<div class="errorTxt1"></div>
</div>
</div>
<div class='row'>
<div class='input-field col s12'>
<input class='validate' type='password' name='password' id='password'/>
<label for='password'>Enter your password</label>
<div class="errorTxt2"></div>
</div>
<label style='float: right;'>
<a class='pink-text' href='#!'><b>Forgot Password?</b></a>
</label>
</div>
<br />
<center>
<div class='row'>
<button type='submit' name='btn_login' class='col s12 btn btn-large waves-effect indigo'>Login</button>
</div>
</center>
</form>
</div>
</div>
</center>
</main>
<script src="/testing123.js"></script>
<!--
Client-side Templates
========================
HTML templates are important prerequisites of modern, rich client applications.
To work their magic, frameworks like Backbone, Angular, Ember, and Knockout require
that you load these templates client-side.
By default, your Gruntfile is configured to automatically load and precompile
client-side JST templates in your `assets/templates` folder, then
include them here automatically (between TEMPLATES and TEMPLATES END).
To customize this behavior to fit your needs, just edit `tasks/pipeline.js`.
For example, here are a few things you could do:
+ Import templates from other directories
+ Use a different template engine (handlebars, jade, dust, etc.)
+ Internationalize your client-side templates using a server-side
stringfile before they're served.
-->
<!--TEMPLATES-->
<!--TEMPLATES END-->
</body>
關於可能使我的所有資產文件(js、css)具有相同內容的任何想法。 特別是為什么這個 html 文件? 謝謝!
如果您需要更多信息,請告訴我。
您應該在項目根目錄的.sailsrc
文件中提供公共路徑。
{
"generators": {
"modules": {}
},
"_generatedWith": {
"sails": "1.2.4",
"sails-generate": "1.17.2"
},
"hooks" : {
"sockets" : false
},
"hooks": {
"session": false
},
"paths": {
"public": "assets"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.