Rumah > Soal Jawab > teks badan
- var items = [
{
name: '英雄联盟',
url: '/lol'
}
];
#sidebar-wrapper
ul.sidebar-nav
each item in items
li
a(href='#')= item.name
Error: /Users/Dave/study/live-streaming-crawler/views/sidebar.jade:2
1| - var items = [
2| {
3| name: '英雄联盟', 4| url: '/lol' 5| }
unexpected text {
怎么样才能正常的多行声明变量呢?写在一行里有点奇怪
巴扎黑2017-04-11 13:28:22
写成这样就行了:
-
var items = [
{
name: '英雄联盟',
url: '/lol'
}
];
如果你嫌这样也难看,那还能写成这样:
- var items = [];
- items[0] = {};
- items[0].name = '英雄联盟';
- items[0].url = '/lol';