我想将图像src显示为动态变量,我在名为displayImage的变量中将默认值声明为字符串:
<div class="col-6 " style="margin-top: 35px;">
<div class="row">
<div class="col-6">
<img src="assets/cardsModels/Anniversaire.png" alt="">
</div>
</div>
</div>
**
this.displayedImage = 'assets/cardsModels/Anniversaire.pnf'
this.displayedImage在构造函数中声明,找不到图像,因此无法显示!
只需在displayedImage
中使用变量,然后为图像设置src
:
您问题的解决方案是更改html like(使用数据绑定):