第一次用template,不是很熟。
以下是一个翻页的template,其中涉及多个data,包括listEquipment、getEquipmentData、callingCloud。
<template name="turn-pages-equipment">
<view class="padding-m flex-center solid-top">
<view class="flex align-center justify-between flex-1">
<view class="{{listEquipment && (getEquipmentData.skip + 1) > 1 && !callingCloud?'':'is-disabled'}}" data-target="-1" bindtap="bindEquipmentTurnPages">
<text class="bbIcon-left"></text>
<text>上页</text>
</view>
<view class="text-gray">
<text>{{getEquipmentData.total}}条</text>
</view>
<view class="text-gray">
<text>{{getEquipmentData.pageCount}} / {{getEquipmentData.skip + 1}}页</text>
</view>
<view class="{{listEquipment && getEquipmentData.pageCount > (getEquipmentData.skip + 1) && !callingCloud?'':'is-disabled'}}" data-target="1" bindtap="bindEquipmentTurnPages">
<text>下页</text>
<text class="bbIcon-right"></text>
</view>
</view>
</view>
</template>
这种多个data的情况,我如何调用?或者有什么可以改进的写法?请各位指教,谢谢。
<template is="turn-pages-equipment" data="{{getEquipmentData}}"></template>
自己摸索了一下,原来这样可以:
<template is="turn-pages-equipment" data="{{listEquipment,callingCloud,...getEquipmentData}}"></template>