index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. properties: {
  5. prefixCls: {
  6. type: String,
  7. value: 'wux-alert',
  8. },
  9. classNames: {
  10. type: null,
  11. value: 'wux-animate--fadeIn',
  12. },
  13. theme: {
  14. type: String,
  15. value: 'balanced',
  16. },
  17. thumb: {
  18. type: String,
  19. value: '',
  20. },
  21. title: {
  22. type: String,
  23. value: '',
  24. },
  25. label: {
  26. type: String,
  27. value: '',
  28. },
  29. closable: {
  30. type: Boolean,
  31. value: false,
  32. },
  33. },
  34. data: {
  35. visible: true,
  36. },
  37. computed: {
  38. classes() {
  39. const { prefixCls, theme } = this.data
  40. const wrap = classNames(prefixCls, {
  41. [`${prefixCls}--${theme}`]: theme,
  42. })
  43. const hd = `${prefixCls}__hd`
  44. const thumb = `${prefixCls}__thumb`
  45. const bd = `${prefixCls}__bd`
  46. const text = `${prefixCls}__text`
  47. const desc = `${prefixCls}__desc`
  48. const ft = `${prefixCls}__ft`
  49. const closable = `${prefixCls}__closable`
  50. return {
  51. wrap,
  52. hd,
  53. thumb,
  54. bd,
  55. text,
  56. desc,
  57. ft,
  58. closable,
  59. }
  60. },
  61. },
  62. methods: {
  63. /**
  64. * 关闭时触发的回调函数
  65. */
  66. onClose() {
  67. if (this.data.closable) {
  68. this.setData({
  69. visible: false
  70. })
  71. }
  72. this.triggerEvent('click')
  73. },
  74. /**
  75. * 点击事件
  76. */
  77. onClick() {
  78. this.triggerEvent('click')
  79. },
  80. },
  81. })