在相同 .jade文件中我有:
script.
if (user)
...//using jQuery to change color theme
以及:
li
-if (user)
a(href='/lougout')
-else
a(href='/login')
如果不存在user
,则第一个在Chrome中导致以下错误:
未经参考的参考:未定义用户
第二个完全没有问题的作用,即Node.js Server/Jade Engine不抱怨。
为什么这样发生?
script
之后的 .
表示其内容是字面的。if (user)
发射到<script>
中,未评估:
<script>
if (user)
... // using jQuery to change color theme
</script>