Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 帕格:我如何在所有页面中包含混音?_Javascript_Html_Pug - Fatal编程技术网

Javascript 帕格:我如何在所有页面中包含混音?

Javascript 帕格:我如何在所有页面中包含混音?,javascript,html,pug,Javascript,Html,Pug,我有一个文件includes/mixins.pug,其中包含一些mixin。我还有一个我正在扩展的主布局文件layouts/default.pug。如何在布局文件中包含这些mixin,以便不必在每页上编写include includes/mixin 例如,对于每个附加的pug文件,我必须这样做。在这种情况下:new_page.pug extends layouts/default include includes/mixins block content +my_mixin('Hello

我有一个文件
includes/mixins.pug
,其中包含一些mixin。我还有一个我正在扩展的主布局文件
layouts/default.pug
。如何在布局文件中包含这些mixin,以便不必在每页上编写
include includes/mixin

例如,对于每个附加的pug文件,我必须这样做。在这种情况下:
new_page.pug

extends layouts/default
include includes/mixins

block content
  +my_mixin('Hello World')
doctype html
html(lang=$localeName)
  block vars
  head
    meta(charset="UTF-8")
    meta(http-equiv="X-UA-Compatible" content="IE=edge")
    meta(name="viewport" content="width=device-width, initial-scale=1.0") 

    block styles
    link(rel="stylesheet" type="text/css" href="/assets/css/styles.min.css")
  body
    block content
layouts/default.pug

extends layouts/default
include includes/mixins

block content
  +my_mixin('Hello World')
doctype html
html(lang=$localeName)
  block vars
  head
    meta(charset="UTF-8")
    meta(http-equiv="X-UA-Compatible" content="IE=edge")
    meta(name="viewport" content="width=device-width, initial-scale=1.0") 

    block styles
    link(rel="stylesheet" type="text/css" href="/assets/css/styles.min.css")
  body
    block content

如何在
布局/default.pug
中包含混音?我在文档中找不到解决方案。

您可以
在视图继承层次结构中包含更高级别的mixin,例如在
layouts/default.pug的顶部。然后,mixin将在所有子视图的范围内可用

include includes/mixins

doctype html
html(lang=$localeName)
...

谢谢非常感谢!