带navbar的页面,多个子页面怎么分开写
weui 上带navbar的页面,多个按钮对应的显示内容是在同一个wxml中写的,如果每个子页面的内容代码很多,能否把它们分别写在其他页面来读取,是用什么方式来读取其他页面的呢?例如图中的“选项一的内容”,“选项二的内容”,“选项三 内容”是用三个
2 回复
可以,用模板__template__就可以了。
history.wxml |
< import src = "../template/template.wxml" /> ... < view class = "weui-tab__content" hidden = "{{activeIndex != 0}}" > < block wx:for = '{{historyList1}}' wx:key = "historyList1" bindtap = 'lookDetail' > < template is = "commentItem-me" data = '{{...item}}' data-hi = 'info' bindtap = 'lookDetail' ></ template > </ block > </ view > < view class = "weui-tab__content" hidden = "{{activeIndex != 1}}" > < block wx:for = '{{historyList2}}' > < template is = "commentItem-others" data = '{{...item}}' ></ template > </ block > </ view > |
template.wxml |
< template name = "commentItem-me" > < view class = 'comment-item' > < text class = 'comment-wall-number' >#{{wallNumber}}</ text > < text class = 'comment-content' >{{content}}</ text > < text class = 'comment-time' >{{time}}</ text > </ view > </ template > < template name = "commentItem-others" > < view class = 'comment-item' > < text class = 'comment-nickname' >{{nickname}}</ text > < text class = 'comment-content' >{{content}}</ text > < text class = 'comment-time' >{{time}}</ text > </ view > </ template > |