paloalto
V2EX  ›  Node.js

怎么在 Jade 模板的 script 中得到后端 (Express) 传过来的参数?

  •  1
     
  •   paloalto · Jun 4, 2014 · 5344 views
    This topic created in 4553 days ago, the information mentioned may be changed or developed.


    经测试,上面的写法有误,求指正。
    3 replies  •  2014-06-04 19:13:29 +08:00
    emric
    emric
    Jun 4, 2014❤️2
    1
    var test = #{currentMode};

    没有记错的话应该是这样.
    NemoAlex
    NemoAlex
    Jun 4, 2014❤️2
    2
    字符串的话可以像 @emric 写的这样,不过要加上引号
    var test = '#{currentMode}';
    其余的类型先转成 JSON 再传吧
    paloalto
    paloalto
    OP
    Jun 4, 2014
    3
    @emric
    @NemoAlex

    多谢。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1884 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 01:14 · PVG 09:14 · LAX 17:14 · JFK 20:14
    ♥ Do have faith in what you're doing.