Jah*_*wer 5 lazy-loading vue.js vuejs3
我试图在组件中使用 vue3.0.0 延迟加载,但收到一些警告。\n当我想在父组件中获取该特定组件时,我收到此错误。我的意思是,当我单击以显示子组件时,我收到以下错误。在错误下我添加了我的代码。请帮我。我不是很专业。
\nruntime-core.esm-bundler.js?5c40:38 \n[Vue warn]: Unhandled error during execution of setup function \n at <AsyncComponentWrapper key=0 > \n at <Profile onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy\xc2\xa0{\xe2\x80\xa6} > > \n at <RouterView> \n at <App>\nruntime-core.esm-bundler.js?5c40:38 \n[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next \n at <AsyncComponentWrapper key=0 > \n at <Profile onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy\xc2\xa0{\xe2\x80\xa6} > > \n at <RouterView> \n at <App>\nRun Code Online (Sandbox Code Playgroud)\n这个错误也
\nruntime-core.esm-bundler.js?5c40:2492 \nUncaught (in promise) TypeError: Cannot read property \'catch\' of undefined\n at load (runtime-core.esm-bundler.js?5c40:2492)\n at setup (runtime-core.esm-bundler.js?5c40:2574)\n at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:155)\n at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:7161)\n at setupComponent (runtime-core.esm-bundler.js?5c40:7117)\n at mountComponent (runtime-core.esm-bundler.js?5c40:5115)\n at processComponent (runtime-core.esm-bundler.js?5c40:5090)\n at patch (runtime-core.esm-bundler.js?5c40:4684)\n at patchBlockChildren (runtime-core.esm-bundler.js?5c40:4999)\n at patchElement (runtime-core.esm-bundler.js?5c40:4960)\nRun Code Online (Sandbox Code Playgroud)\n我的代码就像
\nruntime-core.esm-bundler.js?5c40:38 \n[Vue warn]: Unhandled error during execution of setup function \n at <AsyncComponentWrapper key=0 > \n at <Profile onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy\xc2\xa0{\xe2\x80\xa6} > > \n at <RouterView> \n at <App>\nruntime-core.esm-bundler.js?5c40:38 \n[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next \n at <AsyncComponentWrapper key=0 > \n at <Profile onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy\xc2\xa0{\xe2\x80\xa6} > > \n at <RouterView> \n at <App>\nRun Code Online (Sandbox Code Playgroud)\n我还在路线级别使用延迟加载
\nruntime-core.esm-bundler.js?5c40:2492 \nUncaught (in promise) TypeError: Cannot read property \'catch\' of undefined\n at load (runtime-core.esm-bundler.js?5c40:2492)\n at setup (runtime-core.esm-bundler.js?5c40:2574)\n at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:155)\n at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:7161)\n at setupComponent (runtime-core.esm-bundler.js?5c40:7117)\n at mountComponent (runtime-core.esm-bundler.js?5c40:5115)\n at processComponent (runtime-core.esm-bundler.js?5c40:5090)\n at patch (runtime-core.esm-bundler.js?5c40:4684)\n at patchBlockChildren (runtime-core.esm-bundler.js?5c40:4999)\n at patchElement (runtime-core.esm-bundler.js?5c40:4960)\nRun Code Online (Sandbox Code Playgroud)\n
defineAsyncComponent\ 的回调需要返回Promise导入的组件定义,但目前它什么也不返回:
const Lazy = defineAsyncComponent(() => {\n import(\'../../components/frontend/Lazy.vue\')\n // \xe2\x9d\x8c returns nothing\n})\nRun Code Online (Sandbox Code Playgroud)\n您可以return在回调中添加语句:
const Lazy = defineAsyncComponent(() => {\n return import(\'../../components/frontend/Lazy.vue\')\n})\nRun Code Online (Sandbox Code Playgroud)\n...或删除大括号以隐式返回:
\nconst Lazy = defineAsyncComponent(() => import(\'../../components/frontend/Lazy.vue\'))\nRun Code Online (Sandbox Code Playgroud)\n