zoukankan      html  css  js  c++  java
  • 小程序常用操作,if,for,跳转,弹出提示

    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,
    })
    
  • 相关阅读:
    1.计算机初识
    re模块前瞻后顾 快速
    getattr 对类使用
    sklearn iris快速
    numpy c_
    sorted函数 字典按值倒序 实现
    logging快速入门
    configparser快速应用
    reduce 和 map 函数
    一个简单的类继承
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/11388949.html
Copyright © 2011-2022 走看看