bootstrap4中data-content,放入thymeleaf解析的图片路径
时间: 2024-03-23 14:41:09 浏览: 133
要在Bootstrap 4中使用data-content属性来显示图片,您可以使用Thymeleaf将图像路径添加到该属性中。首先,在HTML代码中,您可以使用以下代码来设置data-content属性:
```html
<button type="button" class="btn btn-secondary" data-toggle="popover" data-content="<img src='/images/example.jpg'>">
Show Image
</button>
```
然后,您可以在Thymeleaf模板中设置图像路径。例如,如果您的图像位于src/main/resources/static/images/example.jpg,您可以在模板中使用以下代码:
```html
<button type="button" class="btn btn-secondary" data-toggle="popover" data-content="<img th:src='@{/images/example.jpg}'>">
Show Image
</button>
```
在该代码中,@{/images/example.jpg}将被解析为正确的图像路径,并在data-content属性中动态地生成图像标记。
阅读全文
相关推荐

















