An error is reported when vue-cli3 route registration is loaded on demand.

vue-cli3 route registration on demand loading, Parsing error: Unexpected token import at src/router.js:

Apr.29,2021

first of all, you'd better post your webpack and eslint configuration files for this kind of problem. Finally, someone in github mentioned this Issues. Go and have a look. It should be that babel-eslint, is not configured, so eslint cannot parse import (.). This new feature results in a report parsing error. Issues

vue-cli3 recommended configuration:

"eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [      
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
}

to use the latest vue-eslint-parser, you must use any of the following settings: ( official instructions )

  1. "extends": ["plugin:vue/recommended"]
  2. "extends": ["plugin:vue/base"]

then write parser to the configuration properties of parserOptions. Parser, as previously written in eslint, should be written directly in config, that is, the outermost properties. ide/configuring-sharpspecifying-parser" rel=" nofollow noreferrer "> eslint official website description

{
    "parser": "babel-eslint",
    "rules": {
        ...
    }
}
There seems to be nothing wrong with the writing of

. The routing code is thrown

Menu