Multi-Line Array Literal

孤者浪人 提交于 2019-12-18 15:12:21

问题


In my Jade template, I'm trying to make an array like so:

- var myArray = [
    'one',
    'two',
    'three'
]

But it doesn't compile. Anyone know why? Being able to have a multi-line array that I can use as a mixin argument would make my code much less verbose.


回答1:


- myArray = ['one']
- myArray.push('two')
- myArray.push('three')

If you wanna.




回答2:


You can use block code:

-
    var myArray = [
        "one",
        "two",
        "three"
    ]

each row, index in myArray



回答3:


You can't do that :( https://github.com/visionmedia/jade/pull/405




回答4:


divesario is right is should look like this:

- var myArray = [
-    'one',
-    'two',
-    'three'
- ]



回答5:


You can, but each line must be prefixed by a '-' - see https://github.com/visionmedia/jade/issues/502



来源:https://stackoverflow.com/questions/9254491/multi-line-array-literal

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