Extjs Sencha Touch:显示数据库中的图像

Extjs Sencha Touch:显示数据库中的图像,extjs,sencha-touch,sencha-touch-2,base64,Extjs,Sencha Touch,Sencha Touch 2,Base64,我不熟悉SenchaTouch,我正在尝试在视图中显示图像。图像源位于我的模型的一个字段中,并且是base64字符串格式。我需要将此字段分配给图像src。当我尝试在图像中设置静态base 64内容时,它工作正常,但当我尝试通过指定字段动态指定时,视图为空 请参阅下面的代码 基于Image base64的内容出现在“附件”字段中 我的视图代码 Ext.define('TechHelp.view.ViewAttachment', { xtyp

我不熟悉SenchaTouch,我正在尝试在视图中显示图像。图像源位于我的模型的一个字段中,并且是base64字符串格式。我需要将此字段分配给图像src。当我尝试在图像中设置静态base 64内容时,它工作正常,但当我尝试通过指定字段动态指定时,视图为空

请参阅下面的代码

基于Image base64的内容出现在“附件”字段中

我的视图代码

 Ext.define('TechHelp.view.ViewAttachment',
            {
                xtype : 'viewattachment',
                  extend : "Ext.form.Panel",
                requires :"Ext.form.FieldSet" ,

      config : {
                    //styleHtmlContent : true,
                    scrollable : 'vertical',
                    title : 'Attachments',
    items : [{
        xtype : "image",
       name : 'attachment',
       src: 'data:image/jpeg;base64,'+'Attachment',
           height:'100px',
       width: '100px'
}, ]
 },

 });
我的模型代码

Ext.define('TechHelp.model.Attachment'{ 扩展:“Ext.data.Model”

config: {
    // define the fields. the default type is string

    fields:// ['customerId','FirstName'],
          [{name:'AttachmentId'},
           {name:'TicketId'},
           {name:'Attachment'},
           {name:'FileName'},
           ],

},
}))


请提供帮助。

您可能应该将数据设置为视图,然后使用tpl打印值:

控制器:

var itemView = Ext.create('TechHelp.view.ViewAttachment');
itemView.setRecord(record);
视图:

config:{
可滚动:“垂直”,
标题:“附件”,
第三方物流:''
....
},
更新记录:函数(记录){
如果(记录)此.setData(记录.data);
}

希望能有所帮助-

我对这一点非常困惑。要使用模型,您需要一个我在代码中没有看到的存储。此外,图像不是一个可以附加存储的对象,因此所采用的方法甚至不起作用。如果要将所有base64数据存储在存储中,则必须提取准确的记录,并使用函数将值推入。
config : {
    scrollable : 'vertical',
    title : 'Attachments',
    tpl: '<img src="data:image/jpeg;base64,{Attachment}" />'
    ....
},

updateRecord: function(record) {
    if (record) this.setData(record.data);
}