先看效果图:

jsx:

import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
import closeImg from '../../images/icons/close.png'
import './FloatLayout.scss' interface IProps {
isOpened: boolean,
onClose: Function,
title: string,
} class FloatLayout extends Component<IProps, {}> { state = {
} handleClose () {
this.props.onClose()
} render () {
const {isOpened, title} = this.props
return (
<View className={isOpened ? "float-layout active" : "float-layout"}>
<View className='float-layout__overlay' onClick={this.handleClose.bind(this)}></View>
<View className='float-layout__container layout'>
<View className='layout-header xmg-border-b'>
{title}
<Image src={closeImg} className='close-img'/>
</View>
<View className='layout-body'>
{this.props.children}
</View>
</View>
</View>
)
}
} export { FloatLayout }

scss:

.flolayout {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
visibility: hidden;
z-index: 810;
transition: visibility 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
&.active {
visibility: visible;
.flolayout__overlay {
opacity: 1;
}
.flolayout__container {
transform: translate3d(0, 0, 0);
}
}
}
.flolayout__overlay {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
background-color: rgba(0, 0, 0, 0.3);
opacity: 0;
transition: opacity 150ms ease-in;
}
.flolayout__container {
position: absolute;
bottom: 0;
width: 100%;
min-height: 600px;
max-height: 950px;
background-color: #fff;
border-radius: 32px 32px 0px 0px;
transform: translate3d(0, 100%, 0);
transition: -webkit-transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
transition: transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
transition: transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1),
-webkit-transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
} .flolayout .layout-header {
position: relative;
padding: 30px 0;
text-align: center;
.close-img {
position: absolute;
right: 28px;
top: 36px;
width: 36px;
height: 36px;
}
}
.flolayout .layout-header__title {
overflow: hidden;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
white-space: nowrap;
color: #333;
font-size: 32px;
display: block;
padding-right: 80px;
}
.flolayout .layout-header__icon {
line-height: 1;
position: absolute;
top: 50%;
right: 18px;
padding: 10px;
transform: translate(0, -50%);
} .flolayout .layout-body {
font-size: 28px;
padding: 20px;
height: 602px;
}
.flolayout .layout-body__content {
position: relative;
height: 500px;
overflow-y: scroll;
}

组件必须传三个参数,

isOpened: boolean, //控制显示
onClose: Function, //处理关闭弹窗逻辑
title: string //标题

基于taro封装底下浮动弹窗组件的更多相关文章

  1. 基于 React 封装的高德地图组件,帮助你轻松的接入地图到 React 项目中。

    react-amap 这是一个基于 React 封装的高德地图组件,帮助你轻松的接入地图到 React 项目中. 文档实例预览: Github Web | Gitee Web 特性 ️ 自动加载高德地 ...

  2. taro-script 0.4 发布,基于Taro v3的js解释器组件

    taro-script Github地址 基于Taro v3开发,支持多端小程序动态加载远程 JavaScript 脚本并执行,支持 ES5 语法 最近更新内容 新增useScriptContext获 ...

  3. 基于ElementUI封装Excel数据导入组件

    由于前端项目使用的是Vue-cli3.0 + TypeScript的架构,所以该组件也是基于ts语法封装的,组件的完整代码如下: <template> <div id="m ...

  4. 基于element-ui封装一个Table模板组件

    大家在做后台管理系统的时候,写的最多的可能就是表格页面了,一般分三部分:搜索功能区.表格内容区和分页器区.一般这些功能都是使用第三方组件库实现,比如说element-ui,或者vuetify.这两个组 ...

  5. Vue.js(24)之 弹窗组件封装

    同事封装了一个弹窗组件,觉得还不错,直接拿来用了: gif图展示: 弹框组件代码: <template> <transition name="confirm-fade&qu ...

  6. 基于vue-simple-uploader封装文件分片上传、秒传及断点续传的全局上传插件

    目录 1. 前言 2. 关于vue-simple-uploader 3. 基于vue-simple-uploader封装全局上传组件 4. 文件上传流程概览 5. 文件分片 6. MD5的计算过程 7 ...

  7. 基于JQ的自定义弹窗组件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 封装React AntD的dialog弹窗组件

    前一段时间分享了基于vue和element所封装的弹窗组件(封装Vue Element的dialog弹窗组件),今天就来分享一个基于react和antD所封装的弹窗组件,反正所使用的技术还是那个技术, ...

  9. 基于highcharts封装的组件-demo&源码

    前段时间做的项目中需要用到highcharts绘制各种图表,其实绘制图表本身代码很简单,但是由于需求很多,有大量的图形需要绘制,所以就不得不复制粘贴大量重复(默认配置等等)的代码,所以,后来抽空自己基 ...

随机推荐

  1. C语言:打印所有char字符

    #include <stdio.h> int main() { int aa; char bla; for(aa=0;aa<=255;aa++) { if(aa%10==0 and ...

  2. Vue.js源码解析-Vue初始化流程之动态创建DOM

    目录 前言 一._update 如何判断是初始化还是更新操作? 二.patch 2.1 patch 定义 2.2 初始化的 patch 三.createElm 动态创建DOM 3.1 创建组件节点 3 ...

  3. File类与常用IO流第十一章——打印流

    第十一章.打印流 概述:java.io.PrintStream extends OutputStream,为其他输出流添加了功能,使题目能够方便的打印各种数据值表示形式. 特点: 只负责数据的输出,不 ...

  4. Scala学习——函数高级操作

    scala函数高级操作 一.字符串高级操作 多行字符串和插值 package top.ruandb.scala.Course06 object StringApp { def main(args: A ...

  5. Hive——基本DML语句

    Hive--基本DML语句 DML:Data Manipulation Language(数据操作语言,与关系型数据库相似) 官方手册:https://cwiki.apache.org/conflue ...

  6. Pytest单元测试框架之parametrize参数化

    1.参数化的本质:相同的步骤,但测试数据不同,比如登录的场景 import mathimport pytest# 方式一:分离出Listdef list_Test(): list = [ [2, 2, ...

  7. 版本号是通过import合并而来的,不是继承来的

  8. OpenFaaS实战之五:大话watchdog

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  9. 【进阶之路】Java的类型擦除式泛型

    Java选择的泛型类型叫做类型擦除式泛型.什么是类型擦除式泛型呢?就是Java语言中的泛型只存在于程序源码之中,在编译后的字节码文件里,则全部泛型都会被替换为原来的原始类型(Raw Type),并且会 ...

  10. Java 在Word中创建多级项目符号列表和编号列表

    本文分享通过Java程序代码在Word中创建多级项目符号列表和编号列表的方法.程序运行环境如下: IntelliJ IDEA 2018(JDK 1.8.0) Word 2013 Word Jar包:F ...