Gravatar图像不会在Ext JS标头上呈现。 Gravatar的代码块不起作用

时间:2019-03-28 14:20:21

标签: extjs extjs6 gravatar

我使用两个类在标题上显示图像:'Foresto.ux.Gravatar','Foresto.views.account.Account'。我希望将其放在主标题上。但是控制台将其抛出:“未捕获的ReferenceError:未定义hex_md5”

我尝试了更改方法来调用“ Foresto.views.account.Account”

(ns twitter-search.core
    (:require [twttr.api :as api ]
                    [twttr.auth :refer [env->UserCredentials]]))


(def app-consumer-key "my key from dev.twitter " )

(def creds (env->UserCredentials))

(defn show-user [handle]
    (api/users-show creds :params {:screen_name handle}))



;; The problem I am having is searching for tweets. 
;; When I put the following into the repl:

(api/search-tweets creds :params {:q "football"})

;; It does nothing, other than go from the current namespace 

twitter-search.core=>

;; To 

#_=> 

下一课:

Ext.define('Foresto.ux.Gravatar', {
    extend: 'Ext.Img',
    alias: 'widget.gravatarimg',
    gravatarUrl: '//www.gravatar.com/avatar/',
    imgCls: 'gravatar-img',
    email: '',
    gravatarParams: {
       default: 'identicon',
       size: 80
    },

    initialize: function() {
        this.src = this.getImageUrl(this.email);
        this.callParent();
    },

    getImageUrl: function(email){
        var url = this.gravatarUrl+hex_md5(email).toLowerCase();
        return Ext.urlAppend(url, Ext.Object.toQueryString(this.gravatarParams));
    },

    setEmail:function(email){
        this.setSrc(this.getImageUrl(email));
    }});

然后我在Main.js中称呼它:

Ext.define('Foresto.view.account.Account', {
    extend: 'Foresto.ux.Gravatar',
    autoEl: 'div',
    xtype:'avatest',
    id: 'avatest',
    cls: 'account-control ol-control',
    gravatarParams: {
       default: 'retro',
       size: 36
    }
})

1 个答案:

答案 0 :(得分:1)

在创建Ext.Img实例之前,只需在构造函数中设置src。

Sencha Fiddle