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

uni-app:实现点击按钮出现底部弹窗(uni.showActionSheet+自定义)

一、通过uni.showActionSheet实现底部选择

效果

 代码

<template><view><button @click="showActionsheet">点击打开弹窗</button></view>
</template><script>
export default {methods: {showActionsheet() {uni.showActionSheet({itemList: ['选项1', '选项2', '选项3'],success: (res) => {console.log('选择了第' + (res.tapIndex + 1) + '个选项');},fail: (err) => {console.log('弹窗取消');}});}}
};
</script>

二、自定义底部弹出窗

效果

 代码

<template><view><button @click="togglePopup">点击打开弹窗</button><view v-if="showPopup" class="popup"><view class="content"><view class="line1"><view>料号编辑</view></view><view class="line2"><view>料号:</view><view>料号名称:</view><view>规格型号:</view><view>单位:</view></view></view><view class="btn-group"><view class="btn_position"><view class="cancel" @click="cancel">取消</view><view class="submit" @click="submit">提交</view></view></view></view><view v-if="showPopup" class="mask" @click="togglePopup"></view></view>
</template><script>export default {data() {return {showPopup: false,};},methods: {togglePopup() {this.showPopup = !this.showPopup;},submit() {this.showPopup = false;},cancel() {this.showPopup = false;}}};
</script><style lang="scss">// 弹窗效果.popup {position: fixed;bottom: 0;left: 0;width: 100%;background-color: #fff;// padding: 20rpx;box-sizing: border-box;z-index: 999;}// 遮罩层.mask {position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, 0.5);z-index: 888;}// 弹窗内容.content {.line1 {background-color:#6ea8e7;text-align: center;padding: 20rpx;}.line2 {padding: 20rpx;// border-bottom: 1px solid black;view {margin-bottom: 10rpx;}}}// 按钮样式.btn-group {box-shadow: 0px -2px 6px rgba(0, 0, 0, 0.5); /* 示例阴影参数,根据需要进行调整 */.btn_position {display: flex;width: 100%;.cancel {width: 50%;text-align: center;padding: 20rpx 0;color: #519fe7;}.submit {width: 50%;background-color: #519fe7;text-align: center;padding: 20rpx 0;color: #fff;}}}
</style>

http://www.lryc.cn/news/115042.html

相关文章:

  • flume系列之:监控zookeeper的flume配置写入节点,新增和删除flume agent节点,通过ansible自动部署和卸载flume agent
  • 了解以太网通信中的九阳神功 - SOME/IP协议
  • redis List类型命令
  • 【博客685】prometheus 出现NaN场景以及如何去除干扰(Not a Number)
  • 【计算机网络】网络层协议 -- ICMP协议
  • 机器学习---facebook的案例学习
  • OpenMMLab MMDetectionV3.1.0-SAM(环境安装、模型测试、训练以及模型后处理工具)
  • ios_base::out和ios::out、ios_base::in和ios::in、ios_base::app和ios::app等之间有什么区别吗?
  • PostgreSQL 使用SQL
  • Shell编程基础(十四)文本三剑客(grep)
  • Linux root用户执行修改密码命令,提示 Permission denied
  • Java面向对象学习第三部分
  • python+vue生成条形码码并展示
  • 在线高精地图生成算法调研
  • 【干货】商城系统的重要功能特性介绍
  • MYSQL06高级_为什么使用索引、优缺点、索引的设计、方案、聚簇索引、联合索引、注意事项
  • LeetCode 130. 被围绕的区域
  • python中2等于2.0吗,python中【1:2】
  • 【2023年11月第四版教材】《第2章-信息技术发展(第一部分)》
  • 【CSS】说说对BFC的理解
  • ES6学习-Class类
  • C语言经典小游戏之扫雷(超详解释+源码)
  • 算法leetcode|67. 二进制求和(rust重拳出击)
  • 【ASP.NET MVC】第一个登录页面(8)
  • 使用Openoffice或LibreOffice实现World、Excel、PPTX在线预览
  • 20天学会rust(三)没有object的rust怎么面向对象?
  • 整数规划——第三章 全单模矩阵
  • 数据结构和算法
  • [Vulnhub] matrix-breakout-2-morpheus
  • JDK, JRE和JVM之间的区别和联系