美文网首页
同一表中不同cell的加载

同一表中不同cell的加载

作者: EnjoyWT | 来源:发表于2017-01-17 15:56 被阅读11次

wxml

    <view class="articles">
        <block wx:for="{{ articles }}" wx:key="id">
            <template is="{{ 'newsStyle' + item.style }}" data="{{ ...item }}" />
        </block>
    </view>
      //使用模板

template

<!--无图模式-->
<template name="newsStyle0">
    <navigator url="/pages/news/detail?id={{ id }}&chid={{ chid }}&style={{ style }}&tag={{ tag }}">
        <view class="article__item">
            ...
        </view>
    </navigator>
</template>

<!--三图模式-->
<template name="newsStyle1">
    <navigator url="/pages/news/detail?id={{ id }}&chid={{ chid }}&style={{ style }}&tag={{ tag }}">
    <view class="article__item article__item__cover">
       ...
    </view>
    </navigator>
</template>

<!--普通模式-->
<template name="newsStyle2">
    <navigator url="/pages/news/detail?id={{ id }}&chid={{ chid }}&style={{ style }}&tag={{ tag }}">
    <view class="article__item">
       ...
    </view>
    </navigator>
</template>

css

直接在app.wxss中布局,元素命名需要提前思考周详尽量复用

[github上的开源demo][1]
[1]:https://github.com/vace/wechatapp-news-reader

相关文章

网友评论

      本文标题:同一表中不同cell的加载

      本文链接:https://www.haomeiwen.com/subject/qpdmbttx.html