• 图片加载失败,加载默认



    <pre style="color:#000000;font-family:'Consolas';font-size:15.0pt;"><br>
    <span style=""><span style="">&lt;&lt;/span&gt;<span style="color:#000080;font-weight:bold;">img </span><span style="color:#0000ff;font-weight:bold;">src=</span><span style="color:#008000;font-weight:bold;">"&lt;{:config_img($var['img'])}&gt;" </span><span style="color:#0000ff;font-weight:bold;">onerror=</span><span style="color:#008000;font-weight:bold;">"</span><span style="font-style:italic;">showImgDelay</span>(<span style="color:#000080;font-weight:bold;">this</span>,<span style="color:#008000;font-weight:bold;">''</span>,<span style="color:#0000ff;">0</span>)<span style="color:#008000;font-weight:bold;">"</span><span style="">&gt;</span><br>
    &lt;&lt;/span&gt;<span style="color:#000080;font-weight:bold;">script</span><span style="">&gt;</span><br>
        <span style="color:#000080;font-weight:bold;">function </span><span style="font-style:italic;">showImgDelay</span>(imgObj,imgSrc,maxErrorNum){<br>
    <span style="color:#808080;font-style:italic;">//        showSpan.innerHTML += "--" + maxErrorNum;    //</span><span style="color:#808080;font-style:italic;font-family:'宋体';">显示出加载图片出错的次数<br></span><span style="color:#808080;font-style:italic;font-family:'宋体';">        </span><span style="color:#000080;font-weight:bold;">if</span>(maxErrorNum&gt;<span style="color:#0000ff;">0</span>){<br>
                imgObj.<span style="color:#7a7a43;">onerror</span>=<span style="color:#000080;font-weight:bold;">function</span>(){<br>
                    <span style="font-style:italic;">showImgDelay</span>(imgObj,imgSrc,maxErrorNum-<span style="color:#0000ff;">1</span>);<br>
                };<br>
                <span style="color:#7a7a43;">setTimeout</span>(<span style="color:#000080;font-weight:bold;">function</span>(){<br>
                    imgObj.<span style="color:#660e7a;font-weight:bold;">src</span>=imgSrc;<br>
                },<span style="color:#0000ff;">500</span>);<br>
            }<span style="color:#000080;font-weight:bold;">else</span>{<br>
                imgObj.<span style="color:#7a7a43;">onerror</span>=<span style="color:#000080;font-weight:bold;">null</span>;<br>
                imgObj.<span style="color:#660e7a;font-weight:bold;">src</span>=<span style="color:#008000;font-weight:bold;">"/attachs/default.jpg"</span>;<br>
            }<br>
        }<br>
    <span style="">&lt;/&lt;/span&gt;<span style="color:#000080;font-weight:bold;">script</span><span style="">&gt;</span></span></span></span>
    </pre>

  • 相关阅读:
    记一次小程序的数字三分
    ES6
    ESLint中的globals——向ESLint规则中添加全局变量
    在Power BI报表和仪表板中显示刷新日期时间
    在Microsoft Power BI中创建地图的10种方法—2
    在Microsoft Power BI中创建地图的10种方法
    power bi使用按钮来实现页面的转化
    power bi爬取网页
    使用power bi三年各省旅客吞吐量
    体验PowerBI:零基础分分钟生成一份交互报表
  • 原文地址:https://www.cnblogs.com/llkbk/p/7340768.html
Copyright © 2020-2023  润新知