封装 WBXpopup 组件

devtools/2024/9/24 7:50:43/

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

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

javascript">// 用法
<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>
javascript">  //封装的组件
<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.ppmy.cn/devtools/116397.html

相关文章

基于微信小程序的健身房管理系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、SSM项目源码 系统展示 基于微信小程序JavaSpringBootVueMySQL的健…

Delphi 12.2 新增的 WebStencils 尝鲜

WebStencils 是 Delphi 新增的服务器端 WEB 控件 这个玩意怎么用&#xff0c;用起来有意义吗&#xff1f; 试试才知道。以下测试的描述都是基于 Delphi WebBroker 这个 WEB 服务器端框架。 最新出来的&#xff0c;各方面资料很少&#xff0c;官方也没有详细文档&#xff0c;只…

postman发送与返回,GET与POST使用

1.GET 获取主页 发送&#xff1a; uri: ‘/’ 返回&#xff1a; 2.POST 发送密码 发送&#xff1a; uri: ‘/login.html’ 返回&#xff1a; 3.POST 保存参数 发送&#xff1a; 返回&#xff1a; 4.GET 获取参数 在POST密码之后&#xff0c;服务器发送一个H…

研1日记15

1. 文心一言生成&#xff1a; 在PyTorch中&#xff0c;nn.AdaptiveAvgPool1d(1)是一个一维自适应平均池化层。这个层的作用是将输入的特征图&#xff08;或称为张量&#xff09;在一维上进行自适应平均池化&#xff0c;使得输出特征图的大小在指定的维度上变为1。这意味着&…

IT行业的未来:技术变革与创新的持续推动

IT行业的未来&#xff1a;技术变革与创新的持续推动 随着数字化进程的不断加速&#xff0c;信息技术&#xff08;IT&#xff09;行业正迈入一个快速变革的时代。新兴技术如人工智能&#xff08;AI&#xff09;、5G、物联网&#xff08;IoT&#xff09;和区块链&#xff0c;正在…

十三 系统架构设计(考点篇)

1 软件架构的概念 一个程序和计算系统软件体系结构是指系统的一个或者多个结构。结构中包括软件的构件&#xff0c;构件 的外部可见属性以及它们之间的相互关系。 体系结构并非可运行软件。确切地说&#xff0c;它是一种表达&#xff0c;使软件工程师能够&#xff1a; (1)分…

npm发布插件超级简单版

在开源的世界里&#xff0c;每个人都有机会成为贡献者&#xff0c;甚至是创新的引领者。您是否有过这样的想法&#xff1a;开发一个解决特定问题的小工具&#xff0c;让他成为其他开发者手中的利器&#xff1f;今天&#xff0c;我们就来一场实战训练&#xff0c;学习如何将你的…

Apache Cordova/PhoneGap

Apache Cordova和PhoneGap是两个在移动应用开发领域备受关注的开源框架&#xff0c;它们有着紧密的联系和显著的区别。本文将从起源与发展、技术特点、功能与应用、社区与文档资源、性能与限制以及未来发展趋势等多个方面&#xff0c;对Apache Cordova和PhoneGap进行详细探讨。…