Jade Parser: “Anonymous blocks are not allowed unless they are part of a mixin” Error

混江龙づ霸主 提交于 2019-12-25 04:22:14

问题


I've got this error:

"Anonymous blocks are not allowed unless they are part of a mixin"

with this Jade file:

html
    body
        style(type='text/css', media='screen')
        div#div_name
            display: block
            height: 300px

obviously the problem is with display: block - any ideas \ solutions?


回答1:


The following Jade

style(type='text/css', media='screen')
div#div_name
    display: block
    height: 300px

will not compile.

<style type="text/css" media="screen"></style>
<div id="div_name">
    <display><block></block></display>
    <height>...... and then you get an error with the 300px
</div>

To include literal text, put a period at the end of the element.

style(type='text/css', media='screen')
div#div_name.
    display: block
    height: 300px

will compile to:

<style type="text/css" media="screen"></style>
<div id="div_name">
    display: block
    height: 300px
</div>

Now, I’m guessing that’s probably not what you want. I’m guessing you want the div#div_name literally in your style tag, so you should write the following. Notice how the text is indented, and there’s a period at the end of the style element.

style(type='text/css', media='screen').
    div#div_name {
        display: block
        height: 300px
    }

will compile to:

<style type="text/css" media="screen">
    div#div_name {
        display: block
        height: 300px
    }
</style>

Lastly, don't forget to use semicolons in CSS.



来源:https://stackoverflow.com/questions/21137600/jade-parser-anonymous-blocks-are-not-allowed-unless-they-are-part-of-a-mixin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!