ankurk91 / vue-loading-overlay

Vue.js component for full screen loading indicator :cyclone:
https://ankurk91.github.io/vue-loading-overlay/
MIT License
1.25k stars 102 forks source link

vue-loading.min.js:1 Uncaught TypeError: Cannot read properties of null (reading 'parentElement') #109

Closed AlanCorn closed 2 years ago

AlanCorn commented 2 years ago

I'm submitting a ... (check one with "x")

[x] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

Current behavior

I want to use vue-loading-overlay in router navigation.And I use composition API, but I get "vue-loading.min.js:1 Uncaught TypeError: Cannot read properties of null (reading 'parentElement')" in browser console every time router navigates.

my router.js is looks like this.

import {createRouter, createWebHistory} from 'vue-router'
import {notify} from "@kyvg/vue3-notification";
import {myStore} from '@/store'

import {useLoading} from 'vue-loading-overlay'

const $loading = useLoading()
let loader = $loading.show({
    container:null,
    loader: 'bars',
    color: '#3C83F6',
})

const routes = [...]
const router = createRouter({
    history: createWebHistory(),  
    routes
})

router.beforeEach((to, from, next) => {}

router.afterEach((to, from) => {
        loader.hide()                                 // Uncaught TypeError: Cannot read properties of null (reading 'parentElement') at vue-loading.min.js:1:6240         
})

Expected behavior

The router works fine except this error, the error seems doesn‘t matters. So how can I avoid it.

Minimal reproduction of the problem with instructions

ankurk91 commented 2 years ago

https://github.com/ankurk91/vue-loading-overlay/issues/21

AlanCorn commented 2 years ago

Thanks for your help!