FranckFreiburger / vue3-sfc-loader

Single File Component loader for Vue2 and Vue3. Load .vue files directly from your HTML. No node.js environment, no build step.
MIT License
1.03k stars 116 forks source link

Uncaught TypeError: Cannot destructure property `loadModule` of 'undefined' or 'null'. #100

Closed 523952880 closed 5 months ago

523952880 commented 2 years ago

Android 11 Edge 45.09.4.5079

When I use the edge browser of the android phone, I get the following error

Uncaught TypeError: Cannot destructure property loadModule of 'undefined' or 'null'.

const options = {
    moduleCache: {
        vue: Vue
    },
    async getFile(url) {
        const res = await fetch(url)
        if (!res.ok)
            throw Object.assign(new Error(res.statusText + " " + url), { res })
        return {
            getContentData: (asBinary) =>
                asBinary ? res.arrayBuffer() : res.text()
        }
    },
    addStyle(textContent) {
        const style = Object.assign(document.createElement('style'), {
            textContent
        })
        const ref = document.head.getElementsByTagName('style')[0] || null
        document.head.insertBefore(style, ref)
    }
}

const { loadModule } = window['vue3-sfc-loader']

Describe the bug

To Reproduce

Expected behavior

Versions

Additional context

FranckFreiburger commented 5 months ago

This error means that vue3-sfc-loader has not been properly loaded.

To load the umd bundle of vue3-sfc-loader, use :

<script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"></script>