index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/libs/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: ['prefixCls, theme', function(prefixCls, theme) {
  39. const wrap = classNames(prefixCls, {
  40. [`${prefixCls}--${theme}`]: theme,
  41. })
  42. const hd = `${prefixCls}__hd`
  43. const thumb = `${prefixCls}__thumb`
  44. const bd = `${prefixCls}__bd`
  45. const text = `${prefixCls}__text`
  46. const desc = `${prefixCls}__desc`
  47. const ft = `${prefixCls}__ft`
  48. const closable = `${prefixCls}__closable`
  49. return {
  50. wrap,
  51. hd,
  52. thumb,
  53. bd,
  54. text,
  55. desc,
  56. ft,
  57. closable,
  58. }
  59. }],
  60. },
  61. methods: {
  62. /**
  63. * 关闭时触发的回调函数
  64. */
  65. onClose() {
  66. if (this.data.closable) {
  67. this.setData({
  68. visible: false,
  69. })
  70. }
  71. this.triggerEvent('click')
  72. },
  73. /**
  74. * 点击事件
  75. */
  76. onClick() {
  77. this.triggerEvent('click')
  78. },
  79. },
  80. })