解决模态框不显示的问题

之前的代码

User
<script setup lang='ts'>import type { TabsPaneContext } from 'element-plus'
import { reactive, ref, onMounted, computed, Ref } from 'vue';
import { selectedStoreHook, useselectedStore } from "@/store/modules/selected";
import { ElMessage, formContextKey } from 'element-plus';
import { updatezidong } from '@/api/shezhi';
import { router } from "@/router/index";
import { getsendMessageData, getMessageData, changeMessageData } from "@/api/xitong";
// import line-md:person-filled from "@iconify-icons/line-md:person-filled";
const activeName = ref('first')
const store = useselectedStore();
//切换标签***********
const handleClick = (tab: TabsPaneContext, event: Event) => {console.log(tab, event)
}let modalVisible = true
const activeButton = ref('');const handleButtonClick = (buttonText) => {activeButton.value = buttonText;// 这里可以添加处理按钮点击事件的逻辑
};
//全部标为已读***************************let typeid = 1
// 点击按钮显示模态框
const showConfirmationModal = (id) => {modalVisible = true;typeid = id
}
// 用户点击取消按钮
const handleCancel = () => {modalVisible = false;
}
// 用户点击确定按钮
const handleConfirm = () => {// 调用相应的方法,标为已读markAllAsRead();// 关闭模态框modalVisible = false;
}
// 处理模态框关闭事件
const handleModalClose = () => {// 处理模态框关闭时的逻辑
}
// 调用相应的方法,标为已读
const markAllAsRead = () => {if (typeid == 1) {data.value.forEach((element) => {changeMessageData(element.id).then((response) => {if (!response.success) {ElMessage.error(`消息id为${element.id}标记失败`);}});});} else if (typeid == 2) {data1.value.forEach((element) => {changeMessageData(element.id).then((response) => {if (!response.success) {ElMessage.error(`消息id为${element.id}标记失败`);}});});} else if (typeid == 3) {data2.value.forEach((element) => {changeMessageData(element.id).then((response) => {if (!response.success) {ElMessage.error(`消息id为${element.id}标记失败`);}});});}
}//获取数据***********************
const data = ref([]);
const data2 = ref([]);
const data1 = ref([]);
const datas = ref([]);
const fetchData1 = () => {getMessageData().then((response) => {// 在这里处理返回的数据JSON.parse()datas.value = JSON.parse(JSON.stringify(response.data));data.value = [];datas.value = datas.value.reverse()datas.value.forEach(item => {switch (item.typeid) {case 0:switch (item.state) {case 0:item.state = "未读";break;case 1:item.state = "已读";break;case 2:item.state = "已读";break;}item.time = get_time_diff(item.time);data.value.push(item);break;case 1:item.time = get_time_diff(item.time);data1.value.push(item);break;case 2:item.time = get_time_diff(item.time);data2.value.push(item);break;}});});// Mock current timeconst now = new Date().getTime();// Test casesconst result1 = get_time_diff(now - 2 * 24 * 3600 * 1000);const result2 = get_time_diff(now - 2 * 3600 * 1000);const result3 = get_time_diff(now - 2 * 60 * 1000);const result4 = get_time_diff(now - 2 * 1000);// Assertionconsole.log(result1, '2天');console.log(result2, '2小时');console.log(result3, '2分');console.log(result4, '2秒');console.log(get_time_diff(1643183390123))
};function get_time_diff(time) {var diff = '';var time_diff = new Date().getTime() - time;// 计算相差年数var years = Math.floor(time_diff / (365 * 24 * 3600 * 1000));if (years > 0) {diff += years + '年';} else {// 计算相差月数var months = Math.floor(time_diff / (30 * 24 * 3600 * 1000));if (months > 0) {diff += months + '月';} else {// 计算相差天数 var days = Math.floor(time_diff / (24 * 3600 * 1000));if (days > 0) {diff += days + '天';} else {// 计算相差小时数 var leave1 = time_diff % (24 * 3600 * 1000);var hours = Math.floor(leave1 / (3600 * 1000));if (hours > 0) {diff += hours + '小时';} else {// 计算相差分钟数 var leave2 = leave1 % (3600 * 1000);var minutes = Math.floor(leave2 / (60 * 1000));if (minutes > 0) {diff += minutes + '分';} else {// 计算相差秒数 var leave3 = leave2 % (60 * 1000);var seconds = Math.round(leave3 / 1000);if (seconds > 0) {diff += seconds + '秒';}}}}}}return diff;
}const handleArrowClick = (id, typeid) => {console.log('Corresponding ID:', id);store.$patch({messageid: id,})if (typeid != 3) { changeMessageData(id); }//消息已读router.push("/xitong1/messageitem");
};//********** 编辑消息*/
const handleEditMessage = () => {// 在这里添加触发编辑消息的逻辑console.log('编辑消息');
};
onMounted(() => {fetchData1(); // 在组件挂载后发送请求并获取数据
});
</script><template><div><div class="divrow" style="width: 85vw;height: 45vw;"><el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"><el-tab-pane label="通知" name="first"><div class="divcolumn scroll-container" style="width: 85vw;height: 33vw;"><div v-for="(item, index) in data" :key="index"><div style="height: 100px; margin-bottom: 10px;"><el-card class="divrow" style="height: 100px;"><div class="divcolumn"><div style="display: flex;flex-direction: row;"><strong>{{ item.title }}</strong></div><p class="item-content" style="width: 60vw;">{{ item.content }}</p><div class="divrow"><text style=" margin-left: 10px; font-size: small; color: gray;">{{ item.time }}</text><text style=" margin-left: 10px; font-size: 1.1vw; ">{{ item.from }}</text></div></div><img class="arrow-pointer" src="../../assets/svg/向右箭头.svg"style="width: 2.5vw;margin-top: -4.5vw;margin-left: 80vw;" @click="handleArrowClick(item.id, 1)" /></el-card></div></div></div><el-button style="position: absolute;top:-48px;right:320px;z-index: 999999;color: #000;" type="text"@click="handleButtonClick('设置系统推送')" :class="{ 'blue-text': activeButton === '设置系统推送' }"><img src="../../assets/svg/设置2.svg" style="width: 1.2vw;" />设置系统推送</el-button><el-button type="text" style="position: absolute;top:-48px;right:260px;z-index: 999999;color: #000;"@click="handleButtonClick('搜索')" :class="{ 'blue-text': activeButton === '搜索' }"><img src="../../assets/svg/搜索.svg" style="width: 1.2vw;" />搜索</el-button><el-button type="text" style="position: absolute;top:-48px;right:160px;z-index: 999999;color: #000;"@click="handleButtonClick('显示未读')" :class="{ 'blue-text': activeButton === '显示未读' }"><img src="../../assets/svg/设置.svg" style="width: 1.2vw;" />显示未读</el-button><el-button type="text" style="position: absolute;top:-48px;right:30px;z-index: 999999;color: #000;"@click="handleButtonClick('全部标为已读'), showConfirmationModal(1)":class="{ 'blue-text': activeButton === '全部标为已读' }"><img src="../../assets/svg/标签.svg" style="width: 1.2vw;" />全部标为已读</el-button><el-button type="primary" style="position: absolute; top: 34vw; right: 10px;" @click="handleEditMessage">编辑消息</el-button></el-tab-pane><el-tab-pane label="消息" name="second"><div class="divcolumn scroll-container" style="width: 85vw;height: 33vw;"><div v-for="(item, index) in data1" :key="index"><div style="height: 100px; margin-bottom: 10px;"><el-card class="divrow" style="height: 100px;"><div class="divcolumn"><div style="display: flex;flex-direction: row;"><strong>{{ item.title }}</strong></div><p class="item-content" style="width: 60vw;">{{ item.content }}</p><div class="divrow"><text style=" margin-left: 10px; font-size: small; color: gray;">{{ item.time }}</text><text style=" margin-left: 10px; font-size: 1.1vw; ">{{ item.from }}</text></div></div><img class="arrow-pointer" src="../../assets/svg/向右箭头.svg"style="width: 2.5vw;margin-top: -4.5vw;margin-left: 80vw;" @click="handleArrowClick(item.id, 2)" /></el-card></div></div></div><el-button style="position: absolute;top:-48px;right:320px;z-index: 999999;color: #000;" type="text"@click="handleButtonClick('设置系统推送')" :class="{ 'blue-text': activeButton === '设置系统推送' }"><img src="../../assets/svg/设置2.svg" style="width: 1.2vw;" />设置系统推送</el-button><el-button type="text" style="position: absolute;top:-48px;right:260px;z-index: 999999;color: #000;"@click="handleButtonClick('搜索')" :class="{ 'blue-text': activeButton === '搜索' }"><img src="../../assets/svg/搜索.svg" style="width: 1.2vw;" />搜索</el-button><el-button type="text" style="position: absolute;top:-48px;right:160px;z-index: 999999;color: #000;"@click="handleButtonClick('显示未读')" :class="{ 'blue-text': activeButton === '显示未读' }"><img src="../../assets/svg/设置.svg" style="width: 1.2vw;" />显示未读</el-button><el-button type="text" style="position: absolute;top:-48px;right:30px;z-index: 999999;color: #000;"@click="handleButtonClick('全部标为已读'), showConfirmationModal(2)":class="{ 'blue-text': activeButton === '全部标为已读' }"><img src="../../assets/svg/标签.svg" style="width: 1.2vw;" />全部标为已读</el-button></el-tab-pane><el-tab-pane label="待办" name="third"><div class="divcolumn scroll-container" style="width: 85vw;height: 33vw;"><div v-for="(item, index) in data2" :key="index"><div style="height: 100px; margin-bottom: 10px;"><el-card class="divrow" style="height: 100px;"><div class="divcolumn"><div style="display: flex;flex-direction: row;"><strong>{{ item.title }}</strong></div><p class="item-content" style="width: 60vw;">{{ item.content }}</p><div class="divrow"><text style=" margin-left: 10px; font-size: small; color: gray;">{{ item.time }}</text><text style=" margin-left: 10px; font-size: 1.1vw; ">{{ item.from }}</text></div></div><img class="arrow-pointer" src="../../assets/svg/向右箭头.svg"style="width: 2.5vw;margin-top: -4.5vw;margin-left: 80vw;" @click="handleArrowClick(item.id, 3)" /></el-card></div></div></div><el-button style="position: absolute;top:-48px;right:320px;z-index: 999999;color: #000;" type="text"@click="handleButtonClick('设置系统推送')" :class="{ 'blue-text': activeButton === '设置系统推送' }"><img src="../../assets/svg/设置2.svg" style="width: 1.2vw;" />设置系统推送</el-button><el-button type="text" style="position: absolute;top:-48px;right:260px;z-index: 999999;color: #000;"@click="handleButtonClick('搜索')" :class="{ 'blue-text': activeButton === '搜索' }"><img src="../../assets/svg/搜索.svg" style="width: 1.2vw;" />搜索</el-button><el-button type="text" style="position: absolute;top:-48px;right:160px;z-index: 999999;color: #000;"@click="handleButtonClick('显示未完成')" :class="{ 'blue-text': activeButton === '显示未完成' }"><img src="../../assets/svg/设置.svg" style="width: 1.2vw;" />显示未完成</el-button><el-button type="text" style="position: absolute;top:-48px;right:30px;z-index: 999999;color: #000;"@click="handleButtonClick('全部标为已完成'), showConfirmationModal(3)":class="{ 'blue-text': activeButton === '全部标为已完成' }"><img src="../../assets/svg/标签.svg" style="width: 1.2vw;" />全部标为已完成</el-button></el-tab-pane></el-tabs><!-- 模态框 --><el-dialog title="确认操作" :visible.sync="modalVisible" width="30%" @close="handleModalClose"style="z-index: 1000000000;"><p>确定要将所有消息标为已读吗?</p><span slot="footer" class="dialog-footer"><el-button @click="handleCancel">取消</el-button><el-button type="primary" @click="handleConfirm">确定</el-button></span></el-dialog></div></div>
</template><style lang='scss' scoped>
::v-deep .el-tabs__content {overflow: visible;position: relative
}.scroll-container {/* width: 300px; *//* 设置容器的宽度 *//* height: 200px; *//* 设置容器的高度 */overflow: auto;/* 开启滚动功能 */
}.scroll-container::-webkit-scrollbar {width: 0;/* 隐藏滚动条 */
}.arrow-pointer {cursor: pointer;
}.blue-text {color: rgb(102, 168, 255) !important;
}.item-content {white-space: nowrap;/* 禁止换行 */overflow: hidden;/* 隐藏溢出部分 */text-overflow: ellipsis;
}
</style>

原因

1 决定模态框的绑定元素不是ref响应式

将定义的let modalVisible = false
改成 const modalVisible = ref(false)
然后你就会发现关于此常量的赋值全报错
直接在modalVisible 加上.value就好了

2 使用v-model即可

使用 :visible.sync="modalVisible"可能涉及异步

3 模态框在组件放置上的问题

有可能页面的z-index较高 一直覆盖 尝试将模态框的z-index 设置的高一点
或者模态框组件外层加个div并且设置好位置

思路

之后解决问题的时候,发现模态框不显示 可以尝试直接把false改成true 直接看是赋值的问题还是模态框的问题,能排除大部分的问题

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/154259.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

逐字节讲解 Redis 持久化(RDB 和 AOF)的文件格式(一)

前言 相信各位对 Redis 的这两种持久化机制都不陌生&#xff0c;简单来说&#xff0c;RDB 就是对数据的全量备份&#xff0c;AOF 则是增量备份&#xff0c;而从 4.0 版本开始引入了混合方式&#xff0c;以 7.2.3 版本为例&#xff0c;会生成三类文件&#xff1a;RDB、AOF 和记…

java中的接口

接口&#xff08;interface&#xff09; 有时必须从几个类中派生出一个子类&#xff0c;继承它们所有的属性和方法。但是&#xff0c;Java不支持多重继承。有了接口&#xff0c;就可以得到多重继承的效果。 接口(interface)是抽象方法和常量值的定义的集合。 从本质上讲&…

算法——双指针

一、背景知识 双指针&#xff08;Two Pointers&#xff09;&#xff1a;指的是在遍历元素的过程中&#xff0c;不是使用单个指针进行访问&#xff0c;而是使用两个指针进行访问&#xff0c;从而达到相应的目的。对撞时针&#xff1a; 两个指针方向相反对撞指针一般用来解决有序…

SecureCRT -- 使用说明

【概念解释】什么是SSH&#xff1f; SSH的英文全称是Secure Shell 传统的网络服务程序&#xff0c;如&#xff1a;ftp和telnet在本质上都是不安全的&#xff0c;因为它们在网络上用明文传送口令和数据&#xff0c;别有用心的人非常容易就可以截获这些口令和数据。而通过使用SS…

《Deep learning for fine-grained image analysis: A survey》阅读笔记

论文标题 《Deep learning for fine-grained image analysis: A survey》 作者 魏秀参&#xff0c;旷世研究院 初读 摘要 细粒度图像分析&#xff08;FGIA&#xff09;的任务是分析从属类别的视觉对象。 细粒度性质引起的类间小变化和类内大变化使其成为一个具有挑战性的…

筒仓料位监测|敢不敢对“精度”下狠手!您家筒仓料位测得准吗?

您家是不是还在人工敲仓估算&#xff1f; 您能精确知道料位和库存吗&#xff1f; 您能实时看到库存盈亏吗&#xff1f; 筒仓里装了什么&#xff1f;用了多少&#xff1f; 什么时候进料最划算&#xff1f; 您家的筒仓管理方式可靠吗&#xff1f; 上海思伟筒仓料位监测方案 看…

UE5制作场景时的小技巧和注意事项

UE5制作场景时的小技巧和注意事项 一、场景相关 1.1灯光 1.1.1构建完光照,发现场景都是黑的 可能是所有灯光是静态灯光,把skylight改为动态,如果改完之后还是黑色的,那就在构建一次,就应该没问题了 1.1.2场景中有多个动态光会造成阴影闪烁 需要将skylight变为固定 1…

PHP 数组在底层的实现原理

PHP 数组在底层的实现原理可以分为两种类型&#xff1a;基于哈希表的实现和基于有序列表的实现。 1、基于哈希表的实现 PHP 数组的基于哈希表的实现是指&#xff0c;在内部实现中&#xff0c;PHP 使用了哈希表来实现数组的存储和访问操作。 哈希表是一种数据结构&#xff0c…

并行与分布式 第7章 体系结构 上

文章目录 并行与分布式 第7章 体系结构 上7.1 多处理器结构7.1.1 多处理器存储结构分类7.1.2 非共享存储多处理器7.1.3 共享存储多处理器7.1.4 多核结构 7.2 Cache一致性问题7.2.1数据共享引发的问题7.2.2 Cache一致性协议7.2.3 监听协议的实现7.2.4目录式协议 并行与分布式 第…

数据结构~~~~ [队列] ~~~~

文章目录 队列队列的概念与结构队列的接口实现***队列的初始化******队列的销毁******队列的插入与创建节点******队列的删除******队列的队头数据******队列的队尾数据******队列的判空*** 队列 队列的概念与结构 队列的插入数据在队尾出数据在队头&#xff08;尾入头出&…

【0236】聊一聊PG内核中的命令标签(Command Tags、CommandTag、tag_behavior)

1. 什么是命令标签(Command Tags) 当客户端向PG服务下发一个请求时,postgres进程在读取到用户的请求缓冲区之后,需要对从中解析出用户的具体请求,比如:CREATE TABLE、CREATE DATABASE、DROP TABLE、SELECT等具体操作,这里除了会用到后面即将讲的词法分析解析器flex之外…

pytorch下载离线包的网址

下载地址&#xff1a;https://download.pytorch.org/whl/torch_stable.html 安装GPU版本需要安装&#xff1a;torch、torchvision、 注意版本需要对应上 格式&#xff1a;适用cuda版本&#xff0c;torch版本 或者 orchvision版本&#xff0c;cp38就是适用python 3.8版本 下…

PGFNet

方法 MFRM means ‘multi-modal feature refinement mechanism’&#xff0c;MMAFM means ‘multi-modal and multi-scale attention fusion model’&#xff0c;RPM means ‘residual prediction module’ scale attention weights U R S _R^S RS​,U D S _D^S DS​ enhan…

【操作系统】文件系统的逻辑结构与目录结构

文章目录 文件的概念定义属性基本操作 文件的结构文件的逻辑结构文件的目录结构文件控制块&#xff08;FCB&#xff09;索引节点目录结构 文件的概念 定义 在操作系统中&#xff0c;文件被定义为&#xff1a;以计算机硬盘为载体的存储在计算机上的信息集合。 属性 描述文件…

【Redis使用】一年多来redis使用笔记md文档,第(2)篇:命令和数据库操作

Redis 是一个高性能的key-value数据库。本文会让你知道&#xff1a;什么是 nosql、Redis 的特点、如何修改常用Redis配置、写出Redis中string类型数据的增删改查操作命令、写出Redis中hash类型数据的增删改查相关命令、说出Redis中 list 保存的数据类型、使用StrictRedis对象对…

Vue3+Vite实现工程化,插值表达式和v-text以及v-html

1、插值表达式 插值表达式最基本的数据绑定形式是文本插值&#xff0c;它使用的是"Mustache"语法&#xff0c;即 双大括号{{}} 插值表达式是将数据 渲染 到元素的指定位置的手段之一插值表达式 不绝对依赖标签&#xff0c;其位置相对自由插值表达式中支持javascript的…

4、FFmpeg命令行操作5

提取音视频数据 保留封装格式 ffmpeg -i test.mp4 -acodec copy -vn audio.mp4 ffmpeg -i test.mp4 -vcodec copy -an video.mp4 提取视频 保留编码格式:ffmpeg -i test.mp4 -vcodec copy -an test_copy.h264 强制格式:ffmpeg -i test.mp4 …

[uni-app] uni.showToast 一闪而过问题/设定时间无效/1秒即逝

toast一闪就消失 1.猜测频繁点击导致 – 排除 2.猜测再定时器内导致-- 排除 3.和封装的接口调用一起导致 - 是改原因 深挖发现: axios封装中, 对loading/hindloading进行了配置, 看来是 showToast 与 loading等冲突导致的 wx.hideLoading(Object object) 解决办法 再封装的…

【计算机毕业设计】Node.js商城APP-97200,免费送源码,【开题选题+程序定制+论文书写+答辩ppt书写-原创定制程序】

Node.js商城APP的开发 摘 要 在传统的商业模式中&#xff0c;对于日常各类商品&#xff0c;人们习惯于到各种商家店铺购买。然而在快节奏的新时代中&#xff0c;人们不一定能为购买各类商品腾出时间&#xff0c;更不会耐心挑选自己想要的商品。所以设计一个商城APP&#xff0c…

Notpad-- ubuntu下载安装

Notpad-- ubuntu下载安装 下载 Gitee链接&#xff1a; https://gitee.com/cxasm/notepad– 安装 sudo apt install *.deb运行 /opt/apps/com.hmja.notepad/files/Notepad--出错 需要安装qt5 sudo apt-get install qt5-default