1

我对这样的条件语句有一个看法

#{list items: allTasks, as: 'task'}
<div class="task grid_12">

    #{list items:allClients, as: 'client' }
        <div class="client grid_1">

            #{list items:allTasksDone, as: 'taskDone'}

                #{if task.name==taskDone.task.name && client.name ==taskDone.client.name}
                    Done
                #{/if}
                #{else}
                    Not yet
                #{/else}
            #{/list}
        </div>
    #{/list}
</div>
#{/list}

但结果是:如果条件为真,则显示“尚未完成”,如果条件为假,则显示“尚未完成”。
结果似乎是双倍的。
如何解决这个问题?

4

1 回答 1

1

谢谢帕拉科。是的,这是因为循环变量“taskDone”。我已经检查并修改了我的代码,如下所示:

<div class="task grid_24">
<div class="client grid_3">
Task/Client
</div>
#{list items:allClients, as: 'client' }
<div class="client grid_2">
${client.name} </div>
#{/list}
</div>


#{list items: allTasks, as: 'task'}
<div class="task grid_24">
    <div class="client grid_3">
        ${task.name}
    </div>

    #{list items:allClients, as: 'client' }
    %{
        i =0;
        }%
        <div class="client grid_2">
            #{list items:allTasksDone, as: 'taskDone'}

                #{if (taskDone.task == task && taskDone.client == client )}
                %{
                    i++;
                    }%
                #{/if}


            #{/list}
        <div class="taskStatus grid_2">
        #{if i>0}Done#{/if}
            #{else } Not yet#{/else}
        </div>
        </div>

    #{/list}
</div>
#{/list}
于 2013-01-12T10:09:13.987 回答