0

好的,所以我是流星新手,并且数据结构设置有些复杂。假设我被迫保留结构,我的模板需要是什么样子才能显示它?难道我做错了什么?我似乎无法让我当前的代码工作。非常感谢任何帮助或建议!-谢谢

这是我的数据结构:

Tournament: {
    round1:{
        match1:[
            {ToqeLokbLAs9mALd3: {win: true, gamertag: 'gbachik'}},
            {scH8Zb3XMa5ALZNsL: {win: false, gamertag: 'test'}}
        ],
        match2:[
            {c4LQoXGEo6dA8ZtNT: {win: false, gamertag: 'test2'}},
            {TDrZa3QY3AinxXw5D: {win: true, gamertag: 'test3'}}
        ]
    },
    round2:{
        match3: [
            {ToqeLokbLAs9mALd3: {win: true, gamertag: 'gbachik'}},
            {TDrZa3QY3AinxXw5D: {win: false, gamertag: 'test3'}}
        ]
    },
    consolation:{
        match1: [
            {scH8Zb3XMa5ALZNsL: {win: null, gamertag: 'test'}},
            {c4LQoXGEo6dA8ZtNT: {win: null, gamertag: 'test2'}}
        ]
    }
}

我的助手:

Template.index.helpers({
round: function(){
    return Tournaments.findOne({});
}
});

我的路线:

Router.route('/', function() {
this.subscribe('tournaments').wait();
this.render('index');
});

我的静态视图(玉):

.tournament
        ul.round1.of3
            li
                .participant.winner
                    a(href='#')
                        span.participant-title= this
                        span.participant-number 2
                .participant
                    a(href='#')
                        span.participant-title asdasd loser
                        span.participant-number 3
4

1 回答 1

0

查看{{#each}} {{/each}}空格键。它应该让你至少输出一个列表。http://meteorcapture.com/spacebars/

只是关于如何格式化对象的建议,使其更通用。而不是命名它round1round2制作一个通用对象,round然后在对象内部有一个namenumber参数。如果您关心订单,请考虑使用列表作为容器。

于 2015-04-22T12:14:09.650 回答