您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <style>
  2. .passwordProfile__avatar {
  3. display: inline-block;
  4. width: 38px;
  5. height: 38px;
  6. text-align: center;
  7. line-height: 38px;
  8. margin-right: 1em;
  9. text-transform: uppercase;
  10. color: white;
  11. font-family: monospace;
  12. }
  13. </style>
  14. <template>
  15. <div v-bind:style="avatarStyle" class="passwordProfile__avatar">
  16. <span v-if="selected">
  17. <i class="fa fa-check"></i>
  18. </span>
  19. <span v-else>
  20. {{firstLetter}}
  21. </span>
  22. </div>
  23. </template>
  24. <script type="text/ecmascript-6">
  25. export default {
  26. name: 'avatar',
  27. props: {
  28. name: {
  29. type: String,
  30. required: true
  31. },
  32. selected: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. data(){
  38. return {
  39. alphabetColors: {
  40. a: "#5A8770",
  41. b: "#B2B7BB",
  42. c: "#6FA9AB",
  43. d: "#F5AF29",
  44. e: "#0088B9",
  45. f: "#F18636",
  46. g: "#D93A37",
  47. h: "#A6B12E",
  48. i: "#5C9BBC",
  49. j: "#F5888D",
  50. k: "#9A89B5",
  51. l: "#407887",
  52. m: "#9A89B5",
  53. n: "#5A8770",
  54. o: "#D33F33",
  55. p: "#A2B01F",
  56. q: "#F0B126",
  57. r: "#0087BF",
  58. s: "#F18636",
  59. t: "#0087BF",
  60. u: "#B2B7BB",
  61. v: "#72ACAE",
  62. w: "#9C8AB4",
  63. x: "#5A8770",
  64. y: "#EEB424",
  65. z: "#407887"
  66. },
  67. firstLetter: ''
  68. }
  69. },
  70. mounted(){
  71. this.firstLetter = this.$props.name.charAt(0);
  72. },
  73. computed: {
  74. avatarStyle: function() {
  75. return {
  76. backgroundColor: this.$props.selected ? '#333333' : this.alphabetColors[this.firstLetter] || '#5A8770'
  77. }
  78. }
  79. }
  80. }
  81. </script>