爱意满满的作品展示区。
joaner

用户名生成的头像

  •  1
     
  •   joaner · Feb 11, 2018 · 4331 views
    This topic created in 3018 days ago, the information mentioned may be changed or developed.

    简单配置就能填充用户缺省的头像,支持显示 姓,名或首字母,背景颜色来自 Material Design color。

    相比其它类似项目,对中文姓名的支持更加友好。

    https://github.com/joaner/namedavatar


    如果原本的图片无效,就填充<svg>图像到 src 的 data uri

    <img src="invalid.png" alt="李连杰">
    <img alt="Tom Hanks">
    
    <script>
    namedavatar.setImgs(document.querySelector('img[alt]'), 'alt')
    </script>
    

    也支持 vue2 的directive指令方式:

    import { directive } from 'namedavatar'
    Vue.directive('avatar', directive)
    
    <img v-avatar="username">
    

    新做的项目,欢迎大家 review & 建议

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5394 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 06:44 · PVG 14:44 · LAX 23:44 · JFK 02:44
    ♥ Do have faith in what you're doing.