zoukankan      html  css  js  c++  java
  • 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('用户点击取消')
      }
  • 相关阅读:
    Quartz实现动态定时任务
    Springboot跨域和SpringCloud跨域
    java8 LocalDate 判断一年中的标准周末和工作日
    [WIP]iOS/macOS开发中常见的宏解释
    [WIP] Objective-C Runtime调试
    [WIP] iOS课程作业
    macOS 允许任何来源的应用
    Win10系统下移动、复制、删除文件需要管理员权限的解决方法
    flutter MediaQuery获取屏幕宽度高度密度通知栏高度等屏幕信息
    Flutter 获取状态栏高度、appBar高度 和 手机屏幕宽高
  • 原文地址:https://www.cnblogs.com/ynzj123/p/12761565.html
Copyright © 2011-2022 走看看