【问题标题】:How do you run scripts in Jade template sub blocks?您如何在 Jade 模板子块中运行脚本?
【发布时间】:2014-06-07 19:19:33
【问题描述】:

我正在使用 Jade,我有一个模板和一个内容块。我可以在模板中运行脚本,但如何在内容块中运行脚本?

这是一个简单的例子,mintemplate.jade:

doctype html
html
head
    script.
        alert('Layout Ready!');
body
    h1 Test
        block content

和 test.jade:

extends minlayout
script.
    alert('Content Ready!');

block content
    h2 Content

“布局就绪”警报工作正常,但“内容就绪”警报从未出现。

【问题讨论】:

    标签: javascript node.js express pug


    【解决方案1】:

    你需要在块定义下移动脚本声明

    extends minlayout
    
    block content
    
        script.
    
            alert('Content Ready!');
    
        h2 Content
    

    Template Inheritance

    【讨论】:

      猜你喜欢
      • 2015-07-10
      • 2012-12-27
      • 1970-01-01
      • 2016-10-27
      • 2020-11-06
      • 1970-01-01
      • 2018-06-19
      • 2019-03-21
      • 2014-11-26
      相关资源
      最近更新 更多