2023年6月21日发(作者:)
vue中img图⽚加载中以及加载失败显⽰默认图⽚问题加载中默认图⽚:主要是onload事件监听,data中定义变量imgSrc :require('./');
/* **图⽚加载中* */ loadImg($img){ return 'this.οnlοad=null;='+'"'+$img+'";'; },加载失败⽬前⽹上很多都是⽤onerror事件监听,然后给赋值,压根不管⽤啊,试了半天不管⽤。⽤css倒是能轻松解决,具体代码如下:img{ width: 145px; height: 145px; position: relative;&:after{ content: ""; display: inline-block; position: absolute; z-index: 2; top: 0; left: 0; width: 100%; height: 145px; background: url("./") no-repeat; background-size: 100% ; background-color: #fff;}};觉得好⽤的,请点赞,蟹蟹。
2023年6月21日发(作者:)
vue中img图⽚加载中以及加载失败显⽰默认图⽚问题加载中默认图⽚:主要是onload事件监听,data中定义变量imgSrc :require('./');
/* **图⽚加载中* */ loadImg($img){ return 'this.οnlοad=null;='+'"'+$img+'";'; },加载失败⽬前⽹上很多都是⽤onerror事件监听,然后给赋值,压根不管⽤啊,试了半天不管⽤。⽤css倒是能轻松解决,具体代码如下:img{ width: 145px; height: 145px; position: relative;&:after{ content: ""; display: inline-block; position: absolute; z-index: 2; top: 0; left: 0; width: 100%; height: 145px; background: url("./") no-repeat; background-size: 100% ; background-color: #fff;}};觉得好⽤的,请点赞,蟹蟹。
发布评论