我正在使用Webstorm中的Express开发NodeJS项目。我正在从EJS(HTML)文件中引用Javascript文件。
<script src = "public/javascripts/DivManipulations.js">
</script>
但Chrome检索的文件与EJS文件相同,而不是Javascript。我不确定为什么这是幸福的。
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css'/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script src = "public/javascripts/DivManipulations.js">
</script>
<script>
$(document).ready(function () {
$("button").click(function () {
$("h1").toggle(); //This toggle part works
remoteScriptTest("Hi"); //This remoteSrciptTest does not.
});
});
function testCall(){
window.alert("Hi");
}
</script>
</head>
<body style="padding: 0px; margin: 0px;">
<div id="root"></div>
<div style="background-color: red; width: 100px; height: 60px; overflow: auto;">
<span>Some text comes here</span>
</div>
<h1><%= title %> </h1>
</p> Welcome to <%= title %> </p>
<button>Click here</button>
</body>
</html>
这是js文件:
/**
* Created by ---- on 11/21/13.
*/
function remoteScriptTest(message){
window.alert(message);
}
这是package.json
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "3.4.4",
"ejs": "*"
}
}