javascript - 如何在 Datatable 中呈现图像链接
问题描述
我在烧瓶应用程序中有下表。第一列应该呈现一个完整的链接语句,例如:
<a href ="https://www.website.com/i=2xyz2g" target="_blank"> <img src="/static/assets/img/abc.jpg" width="100" height="100"></a>
数据来自查询: 表如下:
|img | Title |
-----------------------------------------------
| the <a> script above goes here | some text|
我想编写 javascript 来呈现图像/链接。
<table id="table_id" class="display compact" style="width:100%"> <thead> <tr> {% for col in img_list_cols %} <th>{{col}}</th> {% endfor %} </tr> </thead> <tbody> {% for row in img_list_rows %} <tr> {% for row_data in row %} <td>{{row_data}}</td> {% endfor %} </tr> {% endfor %} </tbody> </table>
解决方案
您可以使用 Jinjasafe
过滤器,例如。
<td>{{row_data|safe}}</td>
推荐阅读
- java - Java 使用来自不同类中调用的不同方法的 var 值
- pandas-groupby - 查找每个位置 1 月份的平均风速
- java - 启动画面不能在模拟器上工作,但在 android pie 或更高版本上工作正常,也不能在 pie 下工作
- vue.js - 使用 Vue 和 Vuetify 以编程方式设置 v-checkbox
- google-apps-script - 如何在添加新行时从谷歌表(正在收集数据作为网络挂钩)触发电子邮件?
- javascript - 使用纯js循环多个json文件
- android - 如何撤消从房间数据库中删除
- ios - 带有表格视图单元的 UIRefreshControl
- flutter - *已解决*在未来的构建器中使用存储在类中的 json 数据
- python - 我怎样才能简化这个表达式?