当前位置: 首页 > news >正文

uniAPP安装 uni-popup,弹窗提示

在使用前,需要通过 npm 安装 uni-popup:

npm install @dcloudio/uni-ui

在这里插入图片描述
在main.js里全局注册

import Vue from 'vue'
import App from './App'// 导入 uni-popup 组件
import uniPopup from '@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue'
import uniPopupMessage from '@dcloudio/uni-ui/lib/uni-popup-message/uni-popup-message.vue'
import uniPopupDialog from '@dcloudio/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue'// 全局注册 uni-popup 组件
Vue.component('uni-popup', uniPopup)
Vue.component('uni-popup-message', uniPopupMessage)
Vue.component('uni-popup-dialog', uniPopupDialog)// 您的其他代码
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({...App
})
app.$mount()

页面内容

<template><view class="container"><!-- 消息提示弹窗 --><uni-popup ref="messagePopup" type="message"><uni-popup-message type="success" message="操作成功" :duration="2000"></uni-popup-message></uni-popup><!-- 对话框弹窗 --><uni-popup ref="dialogPopup" type="dialog"><uni-popup-dialogtype="info"title="提示"content="确定要执行此操作吗?":duration="0"@confirm="handleConfirm"@close="handleClose"></uni-popup-dialog></uni-popup><!-- 底部弹窗 --><uni-popup ref="bottomPopup" type="bottom"><view class="popup-content"><text class="popup-title">底部弹窗</text><text class="popup-desc">这是一个从底部弹出的窗口</text><button class="popup-btn" @click="closeBottomPopup">关闭</button></view></uni-popup><!-- 操作按钮 --><view class="btn-group"><button class="btn" @click="showMessage">消息提示</button><button class="btn" @click="showDialog">对话框</button><button class="btn" @click="showBottomPopup">底部弹窗</button></view></view>
</template><script>
// 引入 uni-popup 组件
import uniPopup from '@/components/uni-popup/uni-popup.vue'
import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'export default {components: {uniPopup,uniPopupMessage,uniPopupDialog},methods: {// 显示消息提示showMessage() {this.$refs.messagePopup.open()},// 显示对话框showDialog() {this.$refs.dialogPopup.open()},// 显示底部弹窗showBottomPopup() {this.$refs.bottomPopup.open()},// 关闭底部弹窗closeBottomPopup() {this.$refs.bottomPopup.close()},// 对话框确认事件handleConfirm() {console.log('点击确认')this.$refs.dialogPopup.close()},// 对话框关闭事件handleClose() {console.log('点击关闭')this.$refs.dialogPopup.close()}}
}
</script><style scoped>
.container {padding: 30rpx;display: flex;flex-direction: column;align-items: center;
}.btn-group {width: 100%;margin-top: 100rpx;
}.btn {width: 100%;height: 80rpx;line-height: 80rpx;background-color: #007AFF;color: white;border-radius: 10rpx;margin-bottom: 30rpx;font-size: 32rpx;
}.popup-content {padding: 40rpx;background-color: white;border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;display: flex;flex-direction: column;align-items: center;
}.popup-title {font-size: 36rpx;font-weight: bold;margin-bottom: 20rpx;
}.popup-desc {font-size: 28rpx;color: #666;margin-bottom: 40rpx;text-align: center;
}.popup-btn {width: 100%;height: 80rpx;line-height: 80rpx;background-color: #007AFF;color: white;border-radius: 10rpx;
}
</style>

文章转载自:

http://1g0v1c5V.mggwr.cn
http://0bVlxr3b.mggwr.cn
http://yGV17wDg.mggwr.cn
http://LusHX6eK.mggwr.cn
http://6W3hJd1E.mggwr.cn
http://Oj1CbiT1.mggwr.cn
http://ooTx6k9r.mggwr.cn
http://HMPLCf7Y.mggwr.cn
http://CP79Uean.mggwr.cn
http://oPaBUjqI.mggwr.cn
http://x4gr6hon.mggwr.cn
http://HNT82zed.mggwr.cn
http://qh94NMwH.mggwr.cn
http://Waxbses8.mggwr.cn
http://mDMyLoF5.mggwr.cn
http://CwDUsh0M.mggwr.cn
http://38F4l7Ur.mggwr.cn
http://hXFcLiiF.mggwr.cn
http://TALmqkKF.mggwr.cn
http://nzmqjaKV.mggwr.cn
http://ANMGbv76.mggwr.cn
http://5wgVSKN3.mggwr.cn
http://yjzTH8v2.mggwr.cn
http://czpKoLHz.mggwr.cn
http://2rAA3Ou6.mggwr.cn
http://FfND46nn.mggwr.cn
http://l1qsUuxO.mggwr.cn
http://1vfDDAr5.mggwr.cn
http://T3Ay8uKU.mggwr.cn
http://1867pRgl.mggwr.cn
http://www.dtcms.com/a/384235.html

相关文章:

  • 无人机图传系统的功能解析和技术实现原理
  • Linux笔记---HTTPS的原理
  • 如何抓包?iOS 抓包方法、HTTPS 抓包工具选择与手机网络调试全攻略
  • 第22课:DevOps与CI、CD
  • JDK 8调用HTTPS POST接口的SSL配置
  • HTTPS 的加密
  • 基于 EPGF 架构理念的 FaceFusion 3.4.1 本地 .venv 部署教程(非 Conda 环境部署优化版)
  • RabbitMQ 高级功能与优化篇
  • Node.js 高级应用:负载均衡与流量限制
  • Capistrano 让Ruby应用部署变得优雅又简单!
  • [计算机毕业设计]基于深度学习的噪声过滤音频优化系统研究
  • 02-Media-8-uvc_with_csc.py 使用硬件解码的USB摄像头(UVC)捕获视频并显示的程序
  • 【Java】P2 Java 学习路线与JVM、注释方法
  • 【论文阅读—智能驾驶】Diving Deeper Into Pedestrian Behavior Understanding
  • 【论文阅读】LG-VQ: Language-Guided Codebook Learning
  • AI摘桃记:精准率(P-Precision)、召回率(R-Recall)、F1-Score之争
  • 分布式专题——12 RabbitMQ之应用开发
  • 软件可靠性设计:高可用性架构实战——双机热备与集群技术
  • Mac 真正多显示器支持:TESmart USB-C KVM(搭载 DisplayLink 技术)如何实现
  • 鼠标光标消失、触摸板失灵?仅用键盘 3 步救回
  • 漏洞无效化学习
  • 蓝牙鼠标频繁卡顿?一招解决 Win10/11 的 USB 省电机制干扰问题
  • 吱吱企业即时通讯保障企业通讯安全,提升企业部门协作效率
  • 中宇联云计算SD-WAN的售后服务怎么样
  • 【矩阵局部最大值】2022-11-16
  • 矩阵的特征值与特征向量:定义、几何意义与在信号处理中的应用
  • RabbitMQ的文档介绍及使用
  • Python对象序列化完全指南:从基础到高级实战
  • 机器学习实战项目中,回归与分类模型中该如何科学定义目标变量Y?
  • 【Docker】docker容器的使用