当前位置: 首页 > 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>

效果图

在这里插入图片描述

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

相关文章:

  • MATLAB(15)分类模型
  • 非虚拟机安装Centos7连接wifi并开机自动联网
  • 怎么选择的开放式耳机好用?2024超值耳机分享!
  • Web 框架
  • 嗖嗖移动业务大厅(JDBC)
  • 大学生编程入门指南:如何从零开始?
  • 如何基于欧拉系统完成数据库的安装
  • 防御笔记第九天(持续更新)
  • html+css+js前端作业和平精英6个页面页面带js
  • 详解基于百炼平台及函数计算快速上线网页AI助手
  • 【TVM 教程】在 CUDA 上部署量化模型
  • 使用 continue 自定义 AI 编程环境
  • 谷粒商城实战笔记-118-全文检索-ElasticSearch-进阶-aggregations聚合分析
  • ansible,laas,pass,sass
  • 【开源分享】PHP在线提交工单源码|工单管理系统源码 (附源码搭建教程)
  • 【深入探秘Hadoop生态系统】全面解析各组件及其实际应用
  • Flink DataStream API编程入门
  • 案例分享|Alluxio在自动驾驶数据闭环中的应用
  • 为什么选择 Baklib 而不是 Salesforce 进行知识库管理
  • 【C++11】解锁C++11新纪元:深入探索Lambda表达式的奥秘
  • c语言排序(2)
  • vue3+ts+element plus开源框架基础
  • RabbitMQ快速入门(MQ的概念、安装RabbitMQ、在 SpringBoot 项目中集成 RabbitMQ )
  • Linux文件与目录管理命令 ls cp rm mv使用方法
  • KubeSphere 部署的 Kubernetes 集群使用 GlusterFS 存储实战入门
  • elasticsearch源码分析-08Serch查询流程
  • 【协作提效 Go - gin ! swagger】
  • 栈和队列——3.滑动窗口最大值
  • 嵌入式智能手表开发系列文章之开篇
  • 24.8.2数据结构|双链表