微信小程序 WeUI·半屏彈窗

2022-05-12 17:43 更新

Half Screen Dialog

半屏彈窗,輔助完成當(dāng)前頁面任務(wù)時;提醒用戶并引導(dǎo)用戶的下一步操作;用戶主動發(fā)起的任務(wù)時。

代碼引入

在 page.json 中引入組件

{
  "usingComponents": {
    "mp-halfScreenDialog": "../../components/half-screen-dialog/half-screen-dialog"
  }
}

示例代碼

<!--WXML示例代碼-->
<mp-halfScreenDialog 
  bindbuttontap="buttontap"
  show="{{show}}"
  maskClosable="{{false}}" 
  title="測試標(biāo)題B" 
  subTitle="測試標(biāo)題B的副標(biāo)題"
  desc="輔助描述內(nèi)容,可根據(jù)實際需要安排"
  tips="輔助提示內(nèi)容,可根據(jù)實際需要安排"
  buttons="{{buttons}}"
></mp-halfScreenDialog>
<button class="weui-btn" type="primary" bindtap="open">Open</button>
// page.js示例代碼
Page({
    data: {
        show: false,
        buttons: [
            {
                type: 'default',
                className: '',
                text: '輔助操作',
                value: 0
            },
            {
                type: 'primary',
                className: '',
                text: '主操作',
                value: 1
            }
        ]
    },
    open: function () {
        this.setData({
            show: true
        })
    },
    buttontap(e) {
        console.log(e.detail)
    }
});

效果展示

屬性列表

屬性類型默認(rèn)值說明
extClassstring組件類名
closabledbooleantrue是否展示關(guān)閉按鈕
titlestring組件標(biāo)題,可通過slot自定義
subTitlestring組件副標(biāo)題,可通過slot自定義
descstring輔助操作描述內(nèi)容
tipsstring輔助操作提示內(nèi)容
maskClosablebooleantrue點擊遮罩是否關(guān)閉改組件
maskbooleantrue是否需要遮罩層
showbooleantrue是否開啟彈窗
buttonsarray[]輔助操作按鈕列表

自定義事件

事件名稱說明回調(diào)參數(shù)
buttontap點擊輔助操作按鈕時觸發(fā)e.detail = { index, item }
close組件關(guān)閉時候觸發(fā)

Slot

名稱描述
title組件自定義標(biāo)題欄
desc組件自定義操作描述
footer操作按鈕區(qū)域slot


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號