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

uni-app封装组件实现下方滑动弹出模态框

子组件

<template><div class="bottom-modal" :class="{'show': showModal}"><div class="modal-content" :class="{'show': showModal}"><!-- 内容区域 --><slot></slot></div></div></template><script>export default {name: 'BottomModal',props: {showModal: {type: Boolean,default: false}},methods: {}}</script><style lang="scss">.bottom-modal {position: fixed;left: 0;bottom: 0;width: 100%;height: 0;background-color: rgba(0, 0, 0, 0.5);overflow: hidden;transition: height 0.2s ease-out;z-index: 99;}.bottom-modal.show {height: 100%;}.modal-content {background-color: #fff;border-top-left-radius: 10px;border-top-right-radius: 10px;box-shadow: 0px -2px 10px rgba(0, 0, 0, 0.1);padding: 16px;// 内容显示在底部position: absolute;left: 0;bottom: 0;box-sizing: border-box;width: 100%;z-index: 999;height: 0;transition: all 0.5s linear;}.modal-content.show {height: 60vh;}.modal-mask {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}</style>

父组件

<script>
import BottomModal from "@/components/BottomModal.vue"export default {components: {BottomModal},data() {return {showModal: false}},methods: {radioChange(e) {console.log("radioChange", e.detail.value)}}
}
</script>
<template><bottom-modal :showModal="showModal"><view class="my-modal"><text class="title">订单取消</text><text>请选择取消订单的原因:</text><radio-group @change="radioChange"><view><label class="item"><text>商品无货</text><radio :value="1" style="transform: scale(0.6)" /></label></view><view><label class="item"><text>不想要了</text><radio :value="2" style="transform: scale(0.6)" /></label></view><view><label class="item"><text>商品信息填错了</text><radio :value="3" style="transform: scale(0.6)" /></label></view><view><label class="item"><text>地址信息填写错误</text><radio :value="4" style="transform: scale(0.6)" /></label></view><view><label class="item"><text>商品降价</text><radio :value="5" style="transform: scale(0.6)" /></label></view><view><label class="item"><text>其它</text><radio :value="6" style="transform: scale(0.6)" /></label></view></radio-group><view class="cancel-confirm"><text @click="handleCancel">取消</text><text @click="handleConfirm" class="confirm">确认</text></view></view></bottom-modal>
</template><style lang="scss">
.my-modal {display: flex;flex-direction: column;font-size: 26rpx;.item {display: flex;justify-content: space-between;align-items: center;margin-top: 30rpx;padding-right: 30rpx;}.title {margin-top: 15rpx;font-size: 30rpx;text-align: center;}.cancel-confirm {display: flex;justify-content: space-around;margin-top: 30rpx;text {width: 300rpx;height: 60rpx;line-height: 60rpx;text-align: center;border: 1px solid #e6e2e2;border-radius: 30rpx;}.confirm {background-color: #27BA9B;border: none;color: #fff;}}
}
</style>

效果图

在这里插入图片描述

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • NeRF学习——复现训练中的问题记录
  • 【全国大学生电子设计竞赛】2022年E题
  • TCP Analysis Flags 之 TCP Window Full
  • 解决 Vue 页面中地址栏参数变更不刷新的问题
  • react防抖和节流hooks封装
  • Hystrix 线程池策略时使用ThreadLocal
  • 【LeetCode】219.存在重复元素II
  • STM32卡死、跑飞如何调试确定问题
  • CMD运行指令
  • 鸿蒙系统开发【ASN.1密文转换】安全
  • 线程池工具类 Executors源代码详解
  • 基于Redis实现全局唯一id
  • 小试牛刀-Telebot区块链游戏机器人(TS升级)
  • 【Python】数据类型之详讲字符串(下)
  • 全球轻型汽车安全气囊面料市场规划预测:未来六年CAGR为4.3%
  • ERLANG 网工修炼笔记 ---- UDP
  • If…else
  • isset在php5.6-和php7.0+的一些差异
  • JavaScript对象详解
  • JavaScript设计模式系列一:工厂模式
  • JS基础篇--通过JS生成由字母与数字组合的随机字符串
  • LeetCode刷题——29. Divide Two Integers(Part 1靠自己)
  • mockjs让前端开发独立于后端
  • SAP云平台里Global Account和Sub Account的关系
  • 当SetTimeout遇到了字符串
  • 翻译--Thinking in React
  • 分布式熔断降级平台aegis
  • 面试遇到的一些题
  • 面试总结JavaScript篇
  • 模仿 Go Sort 排序接口实现的自定义排序
  • 那些被忽略的 JavaScript 数组方法细节
  • 如何胜任知名企业的商业数据分析师?
  • 使用前端开发工具包WijmoJS - 创建自定义DropDownTree控件(包含源代码)
  • 【云吞铺子】性能抖动剖析(二)
  • ​软考-高级-系统架构设计师教程(清华第2版)【第1章-绪论-思维导图】​
  • #stm32驱动外设模块总结w5500模块
  • #我与Java虚拟机的故事#连载12:一本书带我深入Java领域
  • $.extend({},旧的,新的);合并对象,后面的覆盖前面的
  • (16)Reactor的测试——响应式Spring的道法术器
  • (175)FPGA门控时钟技术
  • (26)4.7 字符函数和字符串函数
  • (二)JAVA使用POI操作excel
  • (二)Pytorch快速搭建神经网络模型实现气温预测回归(代码+详细注解)
  • (九)c52学习之旅-定时器
  • (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
  • (转)es进行聚合操作时提示Fielddata is disabled on text fields by default
  • (转)winform之ListView
  • (转)拼包函数及网络封包的异常处理(含代码)
  • ***通过什么方式***网吧
  • .gitattributes 文件
  • .NET 3.0 Framework已经被添加到WindowUpdate
  • .NET C# 使用GDAL读取FileGDB要素类
  • .NET C#版本和.NET版本以及VS版本的对应关系
  • .net core webapi 部署iis_一键部署VS插件:让.NET开发者更幸福
  • .NET Core 中的路径问题