angular - Typescript - Check if image src has been fetched and call a function
问题描述
I have the following element on my page:
<img src="https://i.pinimg.com/736x/2c/9d/07/2c9d0704ae49dfde914e2b477bf9279c--stick-figure-profile-pictures.jpg" />
How can I check when the src has been successfully fetched and call a function after that?
解决方案
这是一个答案,让我们尝试一次,
html文件,
<img [src]="imagesource" (load)="doSomething()">
<!--(or)-->
<img src="https://i.pinimg.com/736x/2c/9d/07/2c9d0704ae49dfde914e2b477bf9279c--stick-figure-profile-pictures.jpg" (load)="doSomething()">
打字稿文件,
imagesource="https://i.pinimg.com/736x/2c/9d/07/2c9d0704ae49dfde914e2b477bf9279c--stick-figure-profile-pictures.jpg";
doSomething(){
console.log("Loaded");
//do your stuff
}
如需更多参考,请访问此处
推荐阅读
- python - “AttributeError:模块 'django.contrib.auth.views' 没有属性 'password_reset'” urls.py 中的错误
- c - 输入 10x10 字符表,但无法正确将其分配给数组
- reactjs - 如何根据用户所在的路径返回 jsx
- pandas - 熊猫对子字符串或正则表达式的抱怨
- c++ - c++ struct of struct的向量
- flutter - 使用 InkWell 更改卡片颜色和文本
- c - 矩阵 1 和 2 与 C 中的“AND”和“OR”运算的逻辑乘法
- sql - SQl - 如何在彼此相隔 7 天内抓取重复记录
- kubernetes - 如何让 Ingress 与具有所需端口的游戏服务器一起使用 azure 上的 nodeports
- arrays - 索引超出范围,如果不是。VB.net