我刚刚开始学习 Express for NodeJS,使用 Jade 作为渲染引擎,我有 View 和路由
这是我的观点
布局.jade
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(href='/themes/bootstrap.min.css', rel='stylesheet')
script(src='/javascripts/mygridwidjet.js', type='text/javascript')
body
block content
索引.jade
extends layout
block content
h1= title
p Welcome to #{title}
.content-container-fluid
.row
.cols-sample-area
#Grid
这是我的路线
index.js
exports.index = function(req, res){
res.render('index', { title: 'Football Archive' });
};
我编写了与 #Grid
交互的客户端 JavaScript
现在我真的很困惑在哪里放置客户端 JavaScript。
ps:我是个菜鸟,如果这个问题太愚蠢了,我很抱歉。
最佳答案
您必须将其放在文件夹 public/
中(如果不存在则创建它)
myapp
|
|-node_modules/
| |-express/
| |-socket.io/
|
|-public/
| |-javascripts/
| | |-mygridwidjet.js
| |-...
|
|-server.js
这是一个更复杂的示例(我的应用程序):https://github.com/CraftYourModCorporation/RedstoneHub
关于node.js - jade 和客户端 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21061548/