index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { $wuxToast } from '../../dist/index'
  2. import ad from '../index/ad'
  3. ad({
  4. data: {},
  5. onLoad() {},
  6. showToast() {
  7. $wuxToast().show({
  8. type: 'success',
  9. duration: 1500,
  10. color: '#fff',
  11. text: '已完成',
  12. success: () => console.log('已完成'),
  13. })
  14. // The same as above
  15. // $wuxToast().success('已完成', {
  16. // duration: 1500,
  17. // color: '#fff',
  18. // success: () => console.log('已完成')
  19. // })
  20. },
  21. showToastCancel() {
  22. $wuxToast().show({
  23. type: 'cancel',
  24. duration: 1500,
  25. color: '#fff',
  26. text: '取消操作',
  27. success: () => console.log('取消操作'),
  28. })
  29. // The same as above
  30. // $wuxToast().error('取消操作', {
  31. // duration: 1500,
  32. // color: '#fff',
  33. // success: () => console.log('取消操作')
  34. // })
  35. },
  36. showToastErr() {
  37. $wuxToast().show({
  38. type: 'forbidden',
  39. duration: 1500,
  40. color: '#fff',
  41. text: '禁止操作',
  42. success: () => console.log('禁止操作'),
  43. })
  44. // The same as above
  45. // $wuxToast().warning('禁止操作', {
  46. // duration: 1500,
  47. // color: '#fff',
  48. // success: () => console.log('禁止操作')
  49. // })
  50. },
  51. showToastText() {
  52. $wuxToast().show({
  53. type: 'text',
  54. duration: 1500,
  55. color: '#fff',
  56. text: '文本提示',
  57. success: () => console.log('文本提示'),
  58. })
  59. // The same as above
  60. // $wuxToast().info('文本提示', {
  61. // duration: 1500,
  62. // color: '#fff',
  63. // success: () => console.log('文本提示')
  64. // })
  65. },
  66. showToastIcon() {
  67. $wuxToast().show({
  68. type: 'default',
  69. duration: 1500,
  70. color: '#fff',
  71. icon: 'ios-happy',
  72. text: '自定义图标',
  73. success: () => console.log('自定义图标'),
  74. })
  75. },
  76. showToastReturn() {
  77. if (this.timeout) clearTimeout(this.timeout)
  78. const hide = $wuxToast().show({
  79. type: 'success',
  80. duration: 1500,
  81. color: '#fff',
  82. text: '已完成',
  83. })
  84. this.timeout = setTimeout(hide, 1000)
  85. },
  86. showToastPromie() {
  87. const hide = $wuxToast().show({
  88. type: 'success',
  89. duration: 1500,
  90. color: '#fff',
  91. text: '已完成',
  92. })
  93. // hide.promise.then(() => console.log('success'))
  94. hide.then(() => console.log('success'))
  95. },
  96. })