Now you can see the official website to explain how to load components on demand as follows:
// The combination of vue asynchronous components and webpack's [code chunking point] feature enables on-demand loading
const App = () => import('../component/Login.vue');
We usually report this error when using it:
Module build failed: SyntaxError: Unexpected token
It can be found that Import
reported an error because Babel
couldn’t resolve the error and needed to download the plug-in
cnpm install babel-plugin-syntax-dynamic-import --save-dev
Modify . Babelrc
after downloading
{
"presets": [
["env", { "modules": false }],
"stage-3"
],
"plugins": ["syntax-dynamic-import"]
}
In this way, it can be introduced on demand
Read More:
- Solve the data transfer between vue irrelevant components error: this.$store.commit is not a function
- [Solved] Vue3 Error: export ‘createRouter‘ was not found in ‘vue-router‘
- Error starting vue project these dependencies were not found:create in ./src/router/modules/md.js
- [Solved] Vue initialization error: Cannot Loading the File…
- VUE Echarts Loading Error TypeError: Cannot read property getAttribute of null?
- How to Solve Koa Error: Cannot find module ‘koa-router‘
- [Solved] Vscode Error: “export ‘default‘ (imported as ‘VueRouter‘) was not found in ‘vue-router‘
- You have not accepted the license agreements of the following SDK components
- Filezilla Error: You appear to be behind a NAT router. Please configure the passive mode settings and …
- Report Duplicate keys detected: ‘0’. This may cause an update error in VUE and the solution
- [Solved] Eslint error: /xxx/components/xxx import should occur after import of /xxx/utils/xxx
- [Solved] Vue cli version is @ Vue/cli 4.5.13, and sass is used to report an error
- [Solved] rqt_graph Skipped loading plugin with error & Format: “dot“ not recognized
- Error:scalac: missing or invalid dependency detected while loading class file ***
- [Solved] Pytorch loading model specified GPU card number error or failed to specify
- [Solved] UE4 Error: Serial loading Unknown structure
- [Solved] GBase 8a MPP Database sftp Loading Large File Error
- Vue require Error: node_modules/babel-loader/lib
- Yarn add package loading error: operation not permitted, unlink …