index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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: ['prefixCls, active, rounded', function(prefixCls, active, rounded) {
  29. const wrap = classNames(prefixCls, {
  30. [`${prefixCls}--active`]: active,
  31. [`${prefixCls}--rounded`]: rounded,
  32. })
  33. const row = `${prefixCls}__row`
  34. return {
  35. wrap,
  36. row,
  37. }
  38. }],
  39. },
  40. methods: {
  41. updated(active) {
  42. if (this.data.active !== active) {
  43. this.setData({
  44. active,
  45. })
  46. }
  47. },
  48. updateRows(rows = this.data.rows) {
  49. this.setData({
  50. rowList: [...Array(rows)].map((_, index) => index),
  51. })
  52. },
  53. },
  54. attached() {
  55. this.updateRows()
  56. },
  57. })