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

.net 网站中多线程seo精华网站

.net 网站中多线程,seo精华网站,做网站外链,三合一静态网站上一篇写的本来测试好多型号都无事, 今天下午公司的战斗机vivo横空冒出… 晕 弹框直接显示都出不来了,现在还有用这种老的机型的,但是没办法咯~ 前端遇到这种兼容性的问题就要勇于解决 主要解决了这几点: // 添加图片加载事件 <imgv-if"imageUrl":src"image…

上一篇写的本来测试好多型号都无事, 今天下午公司的战斗机vivo横空冒出…
晕 弹框直接显示都出不来了,现在还有用这种老的机型的,但是没办法咯~ 前端遇到这种兼容性的问题就要勇于解决
主要解决了这几点:

// 添加图片加载事件
<imgv-if="imageUrl":src="imageUrl"@load="handleImageLoad"@error="handleImageError"@click="handleImgClick"
/>// 图片加载完成后再显示
const handleImageLoad = () => {console.log('图片加载完成');imageLoaded.value = true;showPopup();
};

这确保了只有在图片真正加载完成后才显示弹框,避免了空白或闪烁。

多重渲染保护:

const showPopup = () => {requestAnimationFrame(() => {setTimeout(() => {isVisible.value = true;if (popupRef.value) {popupRef.value.style.transform = 'translateZ(0)';}}, 100);});
};

使用 requestAnimationFrame 和 setTimeout 的组合,确保在浏览器的下一帧渲染时才显示,这解决了 vivo 手机上的渲染时机问题。

显示状态控制:
const isVisible = ref(false);
const imageLoaded = ref(false);

const containerStyle = computed(() => ({
visibility: imageLoaded.value ? ‘visible’ : ‘hidden’
}));
使用独立的状态控制显示,而不是直接依赖数据加载。

硬件加速和性能优化:
.popup-container {
-webkit-transform: translateZ(0);
transform: translateZ(0);
backface-visibility: hidden;
perspective: 1000;
will-change: transform;
}

这些 CSS 属性强制启用硬件加速,提高渲染性能。
成功的关键在于:
正确的渲染时机:等待图片加载完成
可靠的显示控制:使用多重状态检查
性能优化:启用硬件加速
渲染队列:使用 requestAnimationFrame 确保正确的渲染顺序
这解决了 vivo 手机上的几个典型问题:
渲染时机不对导致的白屏
硬件加速缺失导致的显示问题
图片加载时机导致的布局问题
建议在类似场景下:
总是等待资源加载完成
使用多重渲染保护
添加必要的性能优化属性
保持良好的状态管理

<template><Teleport to="body"><div v-show="isVisible" class="popup-container" :style="containerStyle"><div class="popup-content" ref="popupRef"><imgv-if="imageUrl":src="imageUrl"@load="handleImageLoad"@error="handleImageError"@click="handleImgClick"/><div class="close-btn" @click="handleClose">×</div></div></div></Teleport>
</template><script setup>
import { ref, getCurrentInstance, onMounted, computed } from "vue";
import { getAdList, getConfing } from "@/api/base";const app = getCurrentInstance();
const proxy = app?.appContext.config.globalProperties;
const adPosition = proxy?.$global.AD_POSITION_HOME_POPUP;const diaData = ref({});
const currentPopupIndex = ref(0);
const isVisible = ref(false);
const popupRef = ref(null);
const imageLoaded = ref(false);
const maxShowCount = ref(0);const imageUrl = computed(() => {return diaData.value[adPosition]?.[currentPopupIndex.value]?.pic || "";
});const containerStyle = computed(() => ({visibility: imageLoaded.value ? "visible" : "hidden",
}));const handleImageLoad = () => {console.log("图片加载完成===");imageLoaded.value = true;if (checkCanShow()) {showPopup();} else {isVisible.value = false;currentPopupIndex.value = -1;}
};const handleImageError = (error) => {console.error("图片加载失败===", error);imageLoaded.value = false;
};const showPopup = () => {if (!checkCanShow()) {isVisible.value = false;currentPopupIndex.value = -1;return;}requestAnimationFrame(() => {setTimeout(() => {isVisible.value = true;if (popupRef.value) {popupRef.value.style.transform = "translateZ(0)";}}, 100);});
};// 处理图片点击
const handleImgClick = () => {if (diaData.value?.[adPosition]?.[currentPopupIndex.value]) {proxy?.$adRouter(diaData.value[adPosition][currentPopupIndex.value]);}
};// 处理关闭按钮点击
const handleClose = () => {incrementShowCount();// 检查是否达到最大显示次数if (!checkCanShow()) {isVisible.value = false; // 隐藏整个弹框(包括遮罩)currentPopupIndex.value = -1;return;}if (currentPopupIndex.value < diaData.value[adPosition]?.length - 1) {// 切换到下一张前重置状态imageLoaded.value = false;currentPopupIndex.value++;} else {isVisible.value = false;currentPopupIndex.value = -1;}
};const getTodayShowCount = () => {const today = new Date().toDateString();const storageKey = "popupShowCount_" + today;return parseInt(localStorage.getItem(storageKey) || "0");
};const incrementShowCount = () => {const today = new Date().toDateString();const storageKey = "popupShowCount_" + today;const currentCount = getTodayShowCount();localStorage.setItem(storageKey, (currentCount + 1).toString());
};const checkCanShow = () => {const currentCount = getTodayShowCount();return currentCount < maxShowCount.value;
};onMounted(async () => {try {// 先获取配置的最大显示次数const configRes = await getConfing({ key: proxy.$global.ImageDialogCount });maxShowCount.value = parseInt(configRes.data[0].configValue || "0");console.log("最大显示次数:", maxShowCount.value);// 检查是否可以显示if (checkCanShow()) {// 获取广告数据const res = await getAdList({regionType: [adPosition],});if (res.data) {diaData.value = res.data;console.log("广告数据获取成功:", diaData.value);// 确保数据存在if (diaData.value[adPosition]?.length > 0) {currentPopupIndex.value = 0;}}} else {console.log("已达到最大显示次数");}} catch (error) {cconsole.log("err的信息", error);}
});
</script><style lang="scss" scoped>
.popup-container {position: fixed;top: 0;left: 0;right: 0;bottom: 0;width: 100vw;height: 100vh;background: rgba(0, 0, 0, 0.5);display: flex;justify-content: center;align-items: center;z-index: 999;margin: 0;padding: 0;-webkit-transform: translateZ(0);transform: translateZ(0);backface-visibility: hidden;perspective: 1000;will-change: transform;
}.popup-content {position: relative;width: fit-content;margin: auto;-webkit-transform: translateZ(0);transform: translateZ(0);img {display: block;width: 80vw;max-height: 80vh;object-fit: contain;-webkit-touch-callout: none;user-select: none;-webkit-user-select: none;pointer-events: auto;backface-visibility: hidden;-webkit-backface-visibility: hidden;}
}.close-btn {position: absolute;top: -30px;right: 0;width: 30px;height: 30px;background: rgba(255, 255, 255, 0.8);border-radius: 50%;display: flex;justify-content: center;align-items: center;cursor: pointer;font-size: 20px;color: #333;z-index: 1000;-webkit-tap-highlight-color: transparent;&:active {background: #fff;}
}
</style>

完整代码 解决~

http://www.yayakq.cn/news/488208/

相关文章:

  • 百度搜索 网站图片凡科网电脑版登录
  • 个人如何申请网站企业信息查询app哪个最好
  • 上海公司注册网站自媒体平台收益
  • 海口建设企业网站长沙网站建设企业
  • 郑州网络营销推广公司信息外汇seo公司
  • 锡林郭勒盟建设工程管理网站做网站的作用
  • 卖文具做网站好还是做电商好环球资源网站
  • 北京孤儿院做义工网站快速建设网站免费视频教程
  • 文本网站代码空两格怎么做京东网站建设的策划书
  • 做ppt一般在什么网站好黑龙江建设网电话
  • 长寿做网站的电话百度北京公司地址全部
  • 网站备案幕布psdh5源码网
  • react 网站开发建设网站最基本的要了解什么
  • 杨颖做的车网站南京自助建站网站
  • 做网站和编程金溪网站建设制作
  • 二次网站开发平台用wix做外贸网站
  • 民治营销网站手机挣钱最快的软件
  • 家里做网站买什么服务器好网页美工制作网站
  • 做网站一般什么问题企业网站建设北京
  • 郸城建设银行网站广西网站建设费用
  • 杰奇小说网站建设宁波住房和建设局网站首页
  • 金融公司网站建设wordpress文章折叠
  • 建网站的工具从本地服务入手做本地网站
  • 建设网站选什么地方的主机门窗网站建设
  • 动态ip可以做网站wordpress安装主题后无法查看媒体
  • 网站的类型有哪几种我想自己建立一个网站
  • 东台建设企业网站建设充值网站多钱
  • 营销型网站页面摸板长网页网站
  • 帝国cms做微网站做服装设计兼职的网站
  • 检测网站速度网站制作 西安