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

封装 WBXpopup 组件

这是Popup组件基于微博小程序,需要改变标签,以及一写方法

支持四个方向抽屉,以及中间弹出功能

// 用法
<template><wbx-view style="height: 100vh;"><!-- 对话框组件 --><wbx-view><wbx-text @click="openpup()">打开</wbx-text></wbx-view><WBXpopupref="popupRef"positionType="center"popupWidth="300px"popupHeight="400px"><template slot="popupContent"><wbx-view ref="drawer" style="padding: 16px;box-sizing: border-box; display: flex;flex-direction:column;justify-items: center;align-items: center;"><wbx-text style="font-size: 18px;height:26px;line-height: 26px;font-weight: 500;color:#000">我们仍在生成您的AI新身份</wbx-text><wbx-view@click="guan()"style="width: 70px; height: 70px; border: 2px solid #000"></wbx-view></wbx-view></template></WBXpopup></wbx-view>
</template><script>
/*** @type WBXAppOption*/
import WBXpopup from "../../commpents/wbx-popup/index.vue"
const pageOptions = {data() {return {};},methods: {openpup() {this.$refs.popupRef.openFn();},guan() {this.$refs.popupRef.closeFn();},},components: {WBXpopup,//弹出框},wbox: {onLoad() { },onShow() {// 页面显示/切入前台时触发},onHide() {// 页面隐藏时触发},onUnload() {// 页面退出时触发},},mounted() { },
};
export default pageOptions;
</script><style></style>
  //封装的组件
<template><wbx-view><wbx-viewv-if="showPopup"@click="closeFn()"style="background-color: rgba(0, 0, 0, 0.5);position: fixed;width: 100vw;height: 100vh;top: 0px;left: 0;display: flex;flex-direction: row;justify-content: center;align-items: center;transition: all 0.5s ease;z-index: 1;"><wbx-view :style="{width:popupWidth,height:popupHeight}" style=" transition: all 0.5s ease;z-index: 2; background-color: #fff;" v-if="positionType=='center'" ><slot name="popupContent"></slot></wbx-view><wbx-view :style="drawerStyle" v-else><slot name="popupContent"></slot></wbx-view></wbx-view></wbx-view>
</template><script>
/*openFn() 打开对话框closeFn() 关闭对话框positionType  从那边出来,抽屉的方向  left right bottom top center popupWidth: 对话框的宽popupHeight: 对话框的高
*/
export default {data() {return {showPopup: false,isOpen: false,};},props: {positionType: {type: String,default: "right",},popupWidth: {type: String,default: "300px",},popupHeight: {type: String,default: "300px",},},computed: {drawerStyle() {const style = {transition: "all 0.5s",zIndex: 2,backgroundColor: "#fff",position: "fixed",};if (this.positionType === "left" || this.positionType === "right") {style.width = this.popupWidth;style.height = "100vh";style[this.positionType] = this.isOpen ? "0px" : `-${this.popupWidth}`;} else  {style.width = "100vw";style.height = this.popupHeight;style[this.positionType] = this.isOpen ? "0" : `-${this.popupHeight}`;} return style;},},methods: {openFn() {this.showPopup = true;this.$nextTick(() => {setTimeout(() => {this.isOpen = true;}, 50);});},closeFn() {this.isOpen = false;setTimeout(() => {this.showPopup = false;}, 500);},},
};
</script>
<style></style>
http://www.lryc.cn/news/444390.html

相关文章:

  • 【OJ刷题】双指针问题6
  • 详解:Tensorflow、Pytorch、Keras(搭建自己的深度学习网络)
  • 【CSS in Depth 2 精译_035】5.5 Grid 网格布局中的子网格布局(全新内容)
  • Java是怎么处理死锁的
  • Effective Java 学习笔记 方法签名设计
  • 毛利超70%、超70+智驾客户,这家AI数据训练服务商刚刚止亏
  • 本地部署高颜值某抑云音乐播放器Splayer并实现无公网IP远程听歌
  • 图像压缩编码(4)--H.26x系列视频压缩编码_2
  • JS渲染锻炼输入表单
  • proteus仿真学习(1)
  • 决策树+随机森林模型实现足球大小球让球预测软件
  • 31省市农业地图大数据
  • http请求包含什么
  • 【基础算法总结】模拟篇
  • 《深度学习》PyTorch 手写数字识别 案例解析及实现 <下>
  • 【笔记】材料分析测试:晶体学
  • 飞塔Fortigate7.4.4的DNS劫持功能
  • Unity 设计模式 之 行为型模式 -【状态模式】【观察者模式】【备忘录模式】
  • 【RabbitMQ】RabbitMQ 的概念以及使用RabbitMQ编写生产者消费者代码
  • openmv与stm32通信
  • C++ STL全面解析:六大核心组件之一----序列式容器(vector和List)(STL进阶学习)
  • 【c数据结构】OJ练习篇 帮你更深层次理解链表!(相交链表、相交链表、环形链表、环形链表之寻找环形入口点、判断链表是否是回文结构、 随机链表的复制)
  • 微软开源GraphRAG的使用教程(最全,非常详细)
  • 使用Refine构建项目(1)初始化项目
  • 【Docker】安装及使用
  • [大语言模型-论文精读] 以《黑神话:悟空》为研究案例探讨VLMs能否玩动作角色扮演游戏?
  • 提升动态数据查询效率:应对数据库成为性能瓶颈的优化方案
  • Prometheus+grafana+kafka_exporter监控kafka运行情况
  • 在vue中:style 的几种使用方式
  • 商城小程序后端开发实践中出现的问题及其解决方法