etaoux/brix

mu组件数组对象中又包含了一个数组,没有递归

Closed this issue · 2 comments

{{#list}}
<tr>
    <td class="left" width="15">
        <i class="iconfont more-icon" mx-click="show">&#377</i>
    </td>
    <td>
        <div class="idea_desc">{{creativeDesc}}</div>
        <ul class="item-pic clearfix">
            {{#picUrls}}
            <li class="current{{__index__}}">
                <img src="{{.}}" width="40" height="40">
            </li>
            {{/picUrls}}
        </ul>
    </td>
    <td class="right" width="80">
        <span class="sendNum">{{sendNum}}</span>
    </td>
    <td class="center" width="230">
        <div class="operation">
            <p><a class="btn btn-blue" href="#">立即发送</a></p>
            {{#if(joinedSentList==0)}}
            <p class="status">
                <em class="color-grey cursor-pointer" mx-click="delaypush{}">加入待发送列表</em>
            </p>
            {{/if(joinedSentList==0)}}
            {{#if(joinedSentList==1)}}
            <p class="status"><em class="mr10">已加入</em><a href="#!/manage/weibo/weibo" target="_blank">查看</a></p>
            {{/if(joinedSentList==1)}}
        </div>
    </td>
</tr>
{{/list}}

这里listpicUrls都是数组,但__index__list的索引,二不是picUrls的索引值

function addArrayIndex(v) {
        for (var i = 0; i < v.length; i++) {
            var o = v[i];
            if (o !== null && typeof(o) === "object") {
                if (i === 0) {
                    o.__first__ = true;
                } else if (i === (v.length - 1)) {
                    o.__last__ = true;
                } else {
                    o.__mid__ = true;
                }
                o.__index__ = i;
            }
        }
    }

这里o如果是数组,没做递归

顶, @keyapril

这个在设计的时候考虑了这个问题,出于性能考虑,不对数组做递归的处理,新的3.0版本基于xtemplate开发,不存在这样的问题。
这种特殊数据结构,有需要可以自己先处理数据。