index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. relations: {
  5. '../skeleton/index': {
  6. type: 'ancestor',
  7. },
  8. },
  9. properties: {
  10. prefixCls: {
  11. type: String,
  12. value: 'wux-skeleton-avatar',
  13. },
  14. size: {
  15. type: String,
  16. value: 'default',
  17. },
  18. shape: {
  19. type: String,
  20. value: 'circle',
  21. },
  22. },
  23. data: {
  24. active: false,
  25. },
  26. computed: {
  27. classes: ['prefixCls, active, size, shape', function(prefixCls, active, size, shape) {
  28. const wrap = classNames(prefixCls, {
  29. [`${prefixCls}--active`]: active,
  30. [`${prefixCls}--${size}`]: size,
  31. [`${prefixCls}--${shape}`]: shape,
  32. })
  33. return {
  34. wrap,
  35. }
  36. }],
  37. },
  38. methods: {
  39. updated(active) {
  40. if (this.data.active !== active) {
  41. this.setData({
  42. active,
  43. })
  44. }
  45. },
  46. },
  47. })