ttys026 / wxapp-identIcon

根据用户openID在小程序客户端随机生成SVG头像的插件.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wxapp-identIcon

根据用户openID在小程序客户端随机生成SVG头像的插件.

使用

  1. clone project或者下载压缩包,因为小程序对代码量有<2M的要求,只需要拷贝dist目录下需要使用的Style到小程序目录中。
  2. 在js文件中引用:
var IdentIcon = require('../../utils/githubStyle/index.js');
  1. 在js文件中使用:
var data = IdentIcon('openID');
this.setData({image: data});

上述例子中openID也可以替换成任意字符串。

4.在wxml中插入图片:

<image src='{{image}}' class='avatar'></image>

截图

Github style:

github style

Robohash Style:

robohash style

Credits

HashTool from https://github.com/emn178/js-sha256

Github style revised from https://github.com/stewartlord/identicon.js

Robohash style revised from https://github.com/nimiq/robohash

About

根据用户openID在小程序客户端随机生成SVG头像的插件.

License:MIT License