我已经使用JADE模板使用express框架创建了一个简单的节点应用程序。
在学习过程中一切都很好,直到我开始尝试运行一些客户端JS,但我不知道该怎么做。
我需要在app / index.js中做些事情来告诉节点有关它们的信息吗?任何帮助将非常感激。
谢谢
玉器
extends layout
block content
h1 Title
script.
console.log("I am running on the client");
Run Code Online (Sandbox Code Playgroud)
app.js
extends layout
block content
h1 Title
script.
console.log("I am running on the client");
Run Code Online (Sandbox Code Playgroud)
layout.jade
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
link(rel='stylesheet', href='/stylesheets/bootstrap.css')
link(rel='stylesheet', href='/stylesheets/style.css')
script(src='/javascripts/jquery-2.1.3.js')
script(src='/javascripts/bootstrap.js')
body
div(class="navbar navbar-inverse navbar-fixed-top")
.container
.navbar-header
button.navbar-toggle(type="button", data-toggle="collapse", data-target=".navbar-collapse")
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href="/") Twitter
div(class="collapse navbar-collapse")
ul(class="nav navbar-nav")
li.active
a(href="#") Home
li
a(href="#about") About
li
a(href="#contact") Contact
block content
Run Code Online (Sandbox Code Playgroud)
任何内联脚本都可以像这样运行
script.
if (usingJade)
console.log('you are awesome')
else
console.log('use jade')
Run Code Online (Sandbox Code Playgroud)
来自Docs。
任何外部JS文件都可以像这样加载:
script(src="/path/to/script.js")
Run Code Online (Sandbox Code Playgroud)
另外,您可能要确保您确实在使用布局文件。Jade建议执行以下操作:
extends ./layout.jade
Run Code Online (Sandbox Code Playgroud)
您拥有文件路径并附加了扩展名的位置。尽管扩展名是可选的,因为您在中指定了jade引擎app.js。
让我知道这会有所帮助!
| 归档时间: |
|
| 查看次数: |
13651 次 |
| 最近记录: |