index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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-paragraph',
  13. },
  14. rows: {
  15. type: Number,
  16. value: 3,
  17. },
  18. rounded: {
  19. type: Boolean,
  20. value: false,
  21. },
  22. },
  23. data: {
  24. active: false,
  25. rowList: [],
  26. },
  27. computed: {
  28. classes() {
  29. const { prefixCls, active, rounded } = this.data
  30. const wrap = classNames(prefixCls, {
  31. [`${prefixCls}--active`]: active,
  32. [`${prefixCls}--rounded`]: rounded,
  33. })
  34. const row = `${prefixCls}__row`
  35. return {
  36. wrap,
  37. row,
  38. }
  39. },
  40. },
  41. methods: {
  42. updated(active) {
  43. if (this.data.active !== active) {
  44. this.setData({
  45. active,
  46. })
  47. }
  48. },
  49. updateRows(rows = this.data.rows) {
  50. this.setData({
  51. rowList: [...Array(rows)].map((_, index) => index),
  52. })
  53. },
  54. },
  55. attached() {
  56. this.updateRows()
  57. },
  58. })