新建一个模板(LIst.wxml)
给模板取名name="listNone",引用时导入页面is="listNone"表示引用哪个模板
<template name="listNone">
<view class="table">
<view class="tr-1">
<view class="th">订单详情</view>
</view>
<view>
<view class="tr">
<view class="td-1" selectable="true">订单号</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.orderNo}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true">业务类型</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.businessType}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true">进厂时间</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.limitedAt}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true" wx:if="{{receiveOrder.businessType=='散货'}}">品名</view>
<view class="td-1" selectable="true" wx:else>箱型</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.boxType}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true" wx:if="{{receiveOrder.businessType=='散货'}}">货重</view>
<view class="td-1" selectable="true" wx:else>箱重</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.weight}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true" wx:if="{{receiveOrder.businessType=='散货'}}">装货地址</view>
<view class="td-1" selectable="true" wx:else>门点</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.store}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true" wx:if="{{receiveOrder.businessType=='散货'}}">卸货地址</view>
<view class="td-1" selectable="true" wx:else>港区</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.harbour}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true" wx:if="{{receiveOrder.businessType=='散货'}}">包装</view>
<view class="td-1" selectable="true" wx:else>提箱点</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.fetchAddress}}</view></view>
</view>
<view class="tr" wx:if="{{receiveOrder.businessType!=='散货'}}">
<view class="td-1" selectable="true">进出口</view>
<view class="td-2" selectable="true"><view><view class='td-border'>{{receiveOrder.cargoType=="import"?'进口':'出口'}}</view></view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true">支付方式</view>
<view class="td-2" selectable="true"><view><view class='td-border'>{{receiveOrder.payType== 'online' ? '平台垫付' : '线下结算'}}</view></view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true">运费</view>
<view class="td-2" selectable="true"><view>{{receiveOrder.freight}}</view></view>
</view>
<view class="tr">
<view class="td-1" selectable="true">留言</view>
<view class="td-4" selectable="true"><view>{{receiveOrder.message}}</view></view>
</view> </view>
</view>
</template>
在需要的页面引用
<import src="../template/list.wxml"/>
<template is="listNone" data="{{receiveOrder}}"></template>
如果一个页面有很多相同的重复代码,或者,多个页面有相同的重复代码,使用模板就方便多了