在 Jade 中使用 JQuery 条件不起作用
Using JQuery in Jade conditional not working
在下面的 Jade 代码中,在条件语句中使用 JQuery 不起作用。尽管如果我将 script. console.log($(document).width())
放在代码顶部附近,它会显示,这表明 JQuery 正常运行。 if rows.length > 0
确实有效。
block content
div.issueContainer.ics
if rows.length > 0
if ($(document).width() < 1000)
p Mobile
else
p Not Mobile
//- each val in rows
//- +createIssueBox(val)
//- div.addMore
//- h1 You can be the voice of change
//- div.multButtons
//- a(href="/issues/submit").submit-button.first Submit an Issue
else
div.addMore
h1 There are no issues currently
a(href="/issues/submit").submit-button Submit an Issue
jQuery 是一个客户端框架,它不能在服务器端运行,其中模板引擎(在您的情况下是 Jade)是 运行.
console.log($(document).width())
起作用的原因是它位于由您的模板生成的客户端脚本中。
在下面的 Jade 代码中,在条件语句中使用 JQuery 不起作用。尽管如果我将 script. console.log($(document).width())
放在代码顶部附近,它会显示,这表明 JQuery 正常运行。 if rows.length > 0
确实有效。
block content
div.issueContainer.ics
if rows.length > 0
if ($(document).width() < 1000)
p Mobile
else
p Not Mobile
//- each val in rows
//- +createIssueBox(val)
//- div.addMore
//- h1 You can be the voice of change
//- div.multButtons
//- a(href="/issues/submit").submit-button.first Submit an Issue
else
div.addMore
h1 There are no issues currently
a(href="/issues/submit").submit-button Submit an Issue
jQuery 是一个客户端框架,它不能在服务器端运行,其中模板引擎(在您的情况下是 Jade)是 运行.
console.log($(document).width())
起作用的原因是它位于由您的模板生成的客户端脚本中。