Vite+Vue3+ElmentPlus在部分浏览器上弹窗无法正常显示的问题

539 阅读1分钟

目前来说,Vite默认会按照es2020标准来编译,弹窗中el-overlay以及类似的内容中CSS

.el-overlay {
	 position: fixed;
	 top: 0; 
	 right: 0;
	 bottom: 0;
	 left: 0;
	 z-index: ;
	 height: 100%;
	 background-color: var(--el-overlay-color-lighter);
	 overflow: auto;
}

top: 0; right: 0; bottom: 0; left: 0;会被编译成inset: 0;,但是360极速浏览器等部分浏览器采用的Chrome内核比较老,还不识别inset,所以无法正常显示。只需要在vite.config.js中配置css的编译目标,设置成更早一点的标准即可,也可以直接设置成主流浏览器版本比如chrome83。

build: {
	cssTarget:'chrome83'
}