简体   繁体   中英

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? 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. You can try following instead.

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

It replaces the hide_section to give you following

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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