简体   繁体   English

在玉器中获取内联js变量

[英]get inline js variable in jade

script.
    var hide_section = 'block';
 .title(style='display:#{hide_section}')

I got undefined any idea why? 我不知道为什么吗? is it because #{hide_section} is expecting variable send from the back? 是因为#{hide_section}期望变量从后面发送? I mean controller. 我的意思是控制器。

script.
    var hide_section = 'block';
.title(style='display:#{hide_section}')

Expects the variable to be put at time of compilation ie in controller. 期望变量在编译时被放入控制器中。 Whereas by your definition its added to browser's javascript context. 而根据您的定义,它已添加到浏览器的javascript上下文中。 You can try following instead. 您可以改为尝试关注。

- var hide_section = "block";
.title(style='display:#{hide_section}')

It replaces the hide_section to give you following 它替换了hide_section以给您以下内容

<div style="display:block" class="title"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM