微信小程序 WeUI·半屏彈窗

2022-05-12 17:43 更新

Half Screen Dialog

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

代碼引入

在 page.json 中引入組件

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

示例代碼

<!--WXML示例代碼-->
<mp-halfScreenDialog 
  bindbuttontap="buttontap"
  show="{{show}}"
  maskClosable="{{false}}" 
  title="測(cè)試標(biāo)題B" 
  subTitle="測(cè)試標(biāo)題B的副標(biāo)題"
  desc="輔助描述內(nèi)容,可根據(jù)實(shí)際需要安排"
  tips="輔助提示內(nèi)容,可根據(jù)實(shí)際需要安排"
  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)
    }
});

效果展示

屬性列表

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

自定義事件

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

Slot

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


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

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)