我的数据库表中有base64 字符串图像。我想将图像从数据库加载到我的多通道应用程序中。我如何绑定它们,直接从数据库中调用字符串?非常感谢。
现在我有这个代码。
HTML
<div data-options="dxView : { name: 'tb_proj_gallery', title: 'tb_proj_gallery', targetFrame: 'navigation' } " >
<div data-options="dxContent : { targetPlaceholder: 'content' } " >
<div class="gallery" data-bind="dxGallery: { width: '100%', height: '100%', dataSource: dataSource, showNavButtons: true }">
<div data-options="dxTemplate : { name: 'item' } " >
<div class="gallery-item">
<img data-bind="attr: { src: 'data:image/jpeg;base64,' + file_name }" />
</div>
</div>
</div>
</div>
JS
KioskAppV2.tb_proj_gallery = function(params) {
"use strict";
var shouldReload = false,
dataSource;
function handletb_proj_galleryModification() {
shouldReload = true;
}
function handleViewShown() {
if(shouldReload) {
shouldReload = false;
dataSource.load();
}
}
dataSource = new DevExpress.data.DataSource({
store: KioskAppV2.db.tb_proj_gallery,
map: function(item) {
return new KioskAppV2.tb_proj_galleryViewModel(item);
}
});
return {
dataSource: dataSource,
viewShown: handleViewShown
};
};
file_name 是 tb_proj_gallery 表中保存图像 base64 字符串的列名。此代码返回与表中相同数量的图像的画廊视图,但图像没有出现。它坏了。如何让它出现?TQ。