You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 line
812 B

  1. <template>
  2. <up-toast ref="upGlobalToastRef" />
  3. <up-notify ref="upGlobalNotifyRef" />
  4. </template>
  5. <script setup>
  6. import { onBeforeUnmount, onMounted, ref } from 'vue'
  7. const upGlobalToastRef = ref(null)
  8. const upGlobalNotifyRef = ref(null)
  9. onMounted(() => {
  10. if (typeof uni === 'undefined' || !uni.$u) return
  11. if (typeof uni.$u.setRootToastRef === 'function') {
  12. uni.$u.setRootToastRef(upGlobalToastRef.value)
  13. }
  14. if (typeof uni.$u.setRootNotifyRef === 'function') {
  15. uni.$u.setRootNotifyRef(upGlobalNotifyRef.value)
  16. }
  17. })
  18. onBeforeUnmount(() => {
  19. if (typeof uni === 'undefined' || !uni.$u) return
  20. if (typeof uni.$u.setRootToastRef === 'function') {
  21. uni.$u.setRootToastRef(null)
  22. }
  23. if (typeof uni.$u.setRootNotifyRef === 'function') {
  24. uni.$u.setRootNotifyRef(null)
  25. }
  26. })
  27. </script>