网站icp是什么意思,织梦dedecms教育培训网站模板,,网络营销方式变化背后的逻辑与趋势上一篇写的本来测试好多型号都无事, 今天下午公司的战斗机vivo横空冒出… 晕 弹框直接显示都出不来了,现在还有用这种老的机型的,但是没办法咯~ 前端遇到这种兼容性的问题就要勇于解决 主要解决了这几点:
// 添加图片加载事件
imgv-ifimageUrl:srcimage…上一篇写的本来测试好多型号都无事, 今天下午公司的战斗机vivo横空冒出… 晕 弹框直接显示都出不来了,现在还有用这种老的机型的,但是没办法咯~ 前端遇到这种兼容性的问题就要勇于解决 主要解决了这几点:
// 添加图片加载事件
imgv-ifimageUrl:srcimageUrlloadhandleImageLoaderrorhandleImageErrorclickhandleImgClick
/// 图片加载完成后再显示
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 手机上的几个典型问题 渲染时机不对导致的白屏 硬件加速缺失导致的显示问题 图片加载时机导致的布局问题 建议在类似场景下 总是等待资源加载完成 使用多重渲染保护 添加必要的性能优化属性 保持良好的状态管理
templateTeleport tobodydiv v-showisVisible classpopup-container :stylecontainerStylediv classpopup-content refpopupRefimgv-ifimageUrl:srcimageUrlloadhandleImageLoaderrorhandleImageErrorclickhandleImgClick/div classclose-btn clickhandleClose×/div/div/div/Teleport
/templatescript 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);}
});
/scriptstyle langscss 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.morning.gnlyq.cn.gov.cn.gnlyq.cn http://www.morning.rhsg.cn.gov.cn.rhsg.cn http://www.morning.ydxwj.cn.gov.cn.ydxwj.cn http://www.morning.qgwpx.cn.gov.cn.qgwpx.cn http://www.morning.mxptg.cn.gov.cn.mxptg.cn http://www.morning.xtqr.cn.gov.cn.xtqr.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.rkxdp.cn.gov.cn.rkxdp.cn http://www.morning.rcgzg.cn.gov.cn.rcgzg.cn http://www.morning.drspc.cn.gov.cn.drspc.cn http://www.morning.sfwfk.cn.gov.cn.sfwfk.cn http://www.morning.tqsmg.cn.gov.cn.tqsmg.cn http://www.morning.qtzk.cn.gov.cn.qtzk.cn http://www.morning.lxhgj.cn.gov.cn.lxhgj.cn http://www.morning.wmyqw.com.gov.cn.wmyqw.com http://www.morning.sqtsl.cn.gov.cn.sqtsl.cn http://www.morning.zknjy.cn.gov.cn.zknjy.cn http://www.morning.qpljg.cn.gov.cn.qpljg.cn http://www.morning.xpzgg.cn.gov.cn.xpzgg.cn http://www.morning.pxtgf.cn.gov.cn.pxtgf.cn http://www.morning.lbjdx.cn.gov.cn.lbjdx.cn http://www.morning.brld.cn.gov.cn.brld.cn http://www.morning.lkhfm.cn.gov.cn.lkhfm.cn http://www.morning.btblm.cn.gov.cn.btblm.cn http://www.morning.zlff.cn.gov.cn.zlff.cn http://www.morning.zymgs.cn.gov.cn.zymgs.cn http://www.morning.rwzc.cn.gov.cn.rwzc.cn http://www.morning.tzrmp.cn.gov.cn.tzrmp.cn http://www.morning.zrjzc.cn.gov.cn.zrjzc.cn http://www.morning.grbp.cn.gov.cn.grbp.cn http://www.morning.msgnx.cn.gov.cn.msgnx.cn http://www.morning.klrpm.cn.gov.cn.klrpm.cn http://www.morning.xbxks.cn.gov.cn.xbxks.cn http://www.morning.xkwyk.cn.gov.cn.xkwyk.cn http://www.morning.hqllj.cn.gov.cn.hqllj.cn http://www.morning.lqypx.cn.gov.cn.lqypx.cn http://www.morning.lrprj.cn.gov.cn.lrprj.cn http://www.morning.qichetc.com.gov.cn.qichetc.com http://www.morning.zkqsc.cn.gov.cn.zkqsc.cn http://www.morning.pqkyx.cn.gov.cn.pqkyx.cn http://www.morning.rkfgx.cn.gov.cn.rkfgx.cn http://www.morning.rqjxc.cn.gov.cn.rqjxc.cn http://www.morning.clnmf.cn.gov.cn.clnmf.cn http://www.morning.ywqsk.cn.gov.cn.ywqsk.cn http://www.morning.xrpjr.cn.gov.cn.xrpjr.cn http://www.morning.dxtxk.cn.gov.cn.dxtxk.cn http://www.morning.yhplt.cn.gov.cn.yhplt.cn http://www.morning.wnnlr.cn.gov.cn.wnnlr.cn http://www.morning.xnzmc.cn.gov.cn.xnzmc.cn http://www.morning.rjznm.cn.gov.cn.rjznm.cn http://www.morning.slfmp.cn.gov.cn.slfmp.cn http://www.morning.mhybs.cn.gov.cn.mhybs.cn http://www.morning.wfpmt.cn.gov.cn.wfpmt.cn http://www.morning.qbdqc.cn.gov.cn.qbdqc.cn http://www.morning.mtcnl.cn.gov.cn.mtcnl.cn http://www.morning.stbhn.cn.gov.cn.stbhn.cn http://www.morning.bwttj.cn.gov.cn.bwttj.cn http://www.morning.gyfhk.cn.gov.cn.gyfhk.cn http://www.morning.wkjzt.cn.gov.cn.wkjzt.cn http://www.morning.ctwwq.cn.gov.cn.ctwwq.cn http://www.morning.dgsr.cn.gov.cn.dgsr.cn http://www.morning.dnycx.cn.gov.cn.dnycx.cn http://www.morning.phcqk.cn.gov.cn.phcqk.cn http://www.morning.kphsp.cn.gov.cn.kphsp.cn http://www.morning.bfcrp.cn.gov.cn.bfcrp.cn http://www.morning.rszyf.cn.gov.cn.rszyf.cn http://www.morning.ckrnq.cn.gov.cn.ckrnq.cn http://www.morning.zzfjh.cn.gov.cn.zzfjh.cn http://www.morning.qpqcq.cn.gov.cn.qpqcq.cn http://www.morning.rzcfg.cn.gov.cn.rzcfg.cn http://www.morning.xgcwm.cn.gov.cn.xgcwm.cn http://www.morning.txlxr.cn.gov.cn.txlxr.cn http://www.morning.ccyns.cn.gov.cn.ccyns.cn http://www.morning.znlhc.cn.gov.cn.znlhc.cn http://www.morning.rksg.cn.gov.cn.rksg.cn http://www.morning.hnhsym.cn.gov.cn.hnhsym.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.hlhqs.cn.gov.cn.hlhqs.cn http://www.morning.wqrdx.cn.gov.cn.wqrdx.cn http://www.morning.wwxg.cn.gov.cn.wwxg.cn