• 04 小程序 showActionSheet showLoading showtoast showModal


    wx.showActionSheet(显示操作菜单)

     

    js

    Page({
      feed:function(){
        wx.showActionSheet({
          itemList: ['分享到QQ', '分享到微信', '返回'],
          success (res) {
            console.log("成功")
          },
          fail (res) {
            console.log("失败")
          }
        })
      },
    

     

    wxml

    <view class="feedback" catchtap="feed">
    <text>显示操作菜单</text>
    </view>
    

     

    wxss

    .feedback{
      margin-top: 50rpx;
      padding: 10rpx 5rpx;
      background-color: yellowgreen;
    }
    
    • wx.showActionSheet 写成 wx:showActionSheet 错了很久

    • feed:function() 与 catchtap="feed"对应


     

    wx.showLoading(显示加载框)

     
     

    js

    Page({
        showloading:function(){
        wx.showLoading({
          title: '加载中',
        })
        setTimeout(function () {
          wx.hideLoading()
        }, 2000)
      },
    

     

    wxml

    <view class="loading" catchtap="showloading">
    <text>显示加载框</text>
    </view>
    &nbsp;
    
    <font color=LightBLue >wxss</font>
    

    .loading{
    margin-top: 50rpx;
    padding: 10rpx 5rpx;
    background-color: yellowgreen;
    }

    
    * catchtap="showloading"与showloading:function()对应
    
    ![](https://img2020.cnblogs.com/blog/1952644/202004/1952644-20200423170019705-521940714.png)
    &nbsp;
    
    ###wx.showtoast(显示提示框)
    &nbsp;
    &nbsp;
    
    <font color=LightBLue >js</font>
    

    Page({
    showtoast:function(){

      wx.showToast({
        title: '成功',
        icon: 'success',
        duration: 2000
      })
    

    },

    &nbsp;
    
    <font color=LightBLue >wxml</font>
    
    加载框 ```  

    wxss

    .toast{
      margin-top: 50rpx;
      padding: 10rpx 5rpx;
      background-color: yellowgreen;
    }
    
    • catchtap="toast"与 showtoast:function() 对应


     

    wx.showModal(显示模态对话框)

     
     

    js

    Page({
      showModal:function(){
          
        wx.showModal({
          title: '提示',
          content: '这是一个模态弹窗',
          success (res) {
            if (res.confirm) {
              console.log('用户点击确定')
            } else if (res.cancel) {
              console.log('用户点击取消')
            }
          }
        })
      },
    

     

    wxml

    <view class="Modal" catchtap="showModal">
    <text>加载框</text>
    </view>
    

     

    wxss

    .Modal{
      margin-top: 50rpx;
      padding: 10rpx 5rpx;
      background-color: yellowgreen;
    }
    
    • 控制台可输出 console.log 的内容


     
     

    总结:

    • 都有 点击名:function()
    • wx.事件
    • 在 pag 内。
    • 可以 success (res) , fail (res) ;也可以success (res) {
      if (res.confirm) {
      console.log('用户点击确定')
      } else if (res.cancel) {
      console.log('用户点击取消')
      }
  • 相关阅读:
    MoSQL
    Open Search Server 1.4 Beta3 发布
    NxWidgets 1.5 发布,NuttX的GUI开发包
    segatex 7.900 发布,SELinux 策略编辑器
    MySQL Connector/ODBC 5.2.4 发布
    Phing 2.5 发布,PHP 项目构建工具
    SwingX 1.6.5 发布,GUI 工具包
    XWiki 4.4.1 发布,Java 的 Wiki 引擎
    流言终结者——C语言内存管理
    Hudson 3.0 正式版发布,持续集成引擎
  • 原文地址:https://www.cnblogs.com/ynzj123/p/12761565.html
Copyright © 2020-2023  润新知