index.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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() {
  28. const { prefixCls, active, size, shape } = this.data
  29. const wrap = classNames(prefixCls, {
  30. [`${prefixCls}--active`]: active,
  31. [`${prefixCls}--${size}`]: size,
  32. [`${prefixCls}--${shape}`]: shape,
  33. })
  34. return {
  35. wrap,
  36. }
  37. },
  38. },
  39. methods: {
  40. updated(active) {
  41. if (this.data.active !== active) {
  42. this.setData({
  43. active,
  44. })
  45. }
  46. },
  47. },
  48. })