How to display avatar icon with dynamically created name initials

前端 未结 4 444
眼角桃花
眼角桃花 2021-01-14 12:34

I have a requirement that, by passing a name, it should return an avatar icon which contains the first letters of the words contained in that name. For instance: if I pass

4条回答
  •  臣服心动
    2021-01-14 13:24

    Since UI5 1.46.x, such avatar icon controls are available out of the box.

    
    

    * sap.f if UI5 version is lower than 1.73. Otherwise, use the Avatar from sap.m instead!

    createInitials: function(name) { // minimal sample
      return name.split(" ").map(str => str[0]).join("");
    },
    

    OpenUI5 Avatar control with initials

    More samples can be found in https://openui5.hana.ondemand.com/entity/sap.m.Avatar.

提交回复
热议问题