diff --git a/frontend-h5/src/App.vue b/frontend-h5/src/App.vue index 29a98d4..30dc27a 100644 --- a/frontend-h5/src/App.vue +++ b/frontend-h5/src/App.vue @@ -1,3 +1,6 @@ + diff --git a/frontend-h5/src/composables/useToast.js b/frontend-h5/src/composables/useToast.js new file mode 100644 index 0000000..3b002e7 --- /dev/null +++ b/frontend-h5/src/composables/useToast.js @@ -0,0 +1,11 @@ +import { reactive } from 'vue' +const state = reactive({ list: [] }) +let seq = 0 +export function useToast() { + const show = (msg, type = 'info', duration = 2000) => { + const id = ++seq + state.list.push({ id, msg, type }) + setTimeout(() => { state.list = state.list.filter(x => x.id !== id) }, duration) + } + return { state, show } +}