snackbar.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <v-snackbar
  3. v-model="visibility"
  4. :color="color"
  5. :timeout="time"
  6. height="50"
  7. :style="`top: ${top}px; z-index: var(--zIndex-snackbar)`"
  8. centered
  9. top
  10. text
  11. >
  12. <v-icon :color="color">{{ icon }}</v-icon>
  13. {{ text }}
  14. <template v-slot:action="{ attrs }">
  15. <v-btn
  16. icon
  17. color="indigo"
  18. v-bind="attrs"
  19. @click="visibility = false"
  20. >
  21. <v-icon>mdi-close</v-icon>
  22. </v-btn>
  23. <!-- <v-icon :color="white" v-bind="attrs" class="mr-2" @click="visibility = false"> mdi-close </v-icon> -->
  24. <!-- <v-btn
  25. color="blue"
  26. text
  27. v-bind="attrs"
  28. @click="visibility = false"
  29. >
  30. Close
  31. </v-btn> -->
  32. </template>
  33. </v-snackbar>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'snackBar',
  38. data () {
  39. return {
  40. top: 0,
  41. color: 'success',
  42. visibility: false,
  43. text: '',
  44. time: 5000,
  45. icon: 'mdi-check-circle'
  46. }
  47. },
  48. methods: {
  49. info (text) {
  50. this.visibility = false
  51. this.icon = 'mdi-information-slab-circle-outline'
  52. this.color = '#2196F3'
  53. this.text = text
  54. this.visibility = true
  55. },
  56. error (text) {
  57. this.visibility = false
  58. // setTimeout(() => {
  59. this.icon = 'mdi-alert-circle'
  60. this.color = '#F44336'
  61. this.text = text
  62. this.visibility = true
  63. // }, 50)
  64. },
  65. warning (text) {
  66. this.visibility = false
  67. this.icon = 'mdi-alert'
  68. this.color = '#FFC107'
  69. this.text = text
  70. this.visibility = true
  71. },
  72. success (text) {
  73. this.visibility = false
  74. this.icon = 'mdi-check-circle'
  75. this.color = '#4CAF50'
  76. this.text = text
  77. this.visibility = true
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss" scoped>
  83. </style>