问题
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