DEMO
介绍
微信小程序自定义弹窗,日常项目中写的,顺便开源,也方便自己复制粘贴 第一版,有机会慢慢完善
效果图
使用教程
1、复制粘贴 component/modal 文件夹
2、app.json 中引用:
"usingComponents": {
"diy-modal": "/component/modal/index"
}
3、app.js 中:
import diyModal from './component/modal/modal';
App({
diyModal: diyModal,
});
4、page.wxml 中:
<diy-modal id="diy-modal"></diy-modal>
5、page.js 中:
const app = getApp();
app.diyModal.show({
title: '标题',
content: '内容',
tip: '内容下灰色的提示小字',
showCancel: false,
cancelText: '取消',
confirmText: '确定',
confirm(e) {
//点击确定
},
cancel() {
//点击取消
},
});
// 主动隐藏弹窗
app.diyModal.hide()
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有