if
<block wx:if="{{result.child_items}}">
...
</block>
<block wx:else>
...
</block>
for
<block wx:for="{{result.child_items}}">
<block wx:if="{{item.status == 1}}">
<view class="go_finish_btn" data-id="{{item.id}}" bindtap="do_finish_item">核销【{{item.name}}】</view>
</block>
<block wx:if="{{item.status != 1}}">
<view class="finished_btn">
【{{item.name}}】已核销
</view>
</block>
</block>
确认提示
wx.showModal({
title: '提示',
content: '确认进行该操作吗?',
success (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
常规提示
wx.showModal({
title: '提示',
content: data.errdesc
});
获取参数值
<view class="go_finish_btn" data-id="{{item.id}}" bindtap="do_finish_item">核销【{{item.name}}】</view>
do_finish_item: function(e) {
var child_item_id = e.currentTarget.dataset.id;
}
跳转到菜单页
wx.switchTab({
url: '/pages/index/index'
});
跳转到页面,并关闭当前页
wx.redirectTo({
url: '/pages/product/index?id=' + id,
})
跳转到下一页,可以返回上一页
wx.navigateTo({
url: '/pages/product/index?id=' + id,
})
小程序常用操作,if,for,跳转,弹出提示