问题:
在vue项目中配置动态路由时报错
1 |
component: () => import(`@/views/${module}/index.vue`) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
ERROR Failed to compile with 1 errors 09:16:01 error in ./src/views/login/routes.js Module build failed (from ./node_modules/eslint-loader/index.js): TypeError: Cannot read property 'range' of null Occurred while linting H:\project\web\demo\vue-admin-template\src\views\login\routes.js:8 at SourceCode.getTokenBefore (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\source-code\token-store\index.js:298:18) at checkSpacingBefore (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\rules\template-curly-spacing.js:60:42) at TemplateElement (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\rules\template-curly-spacing.js:119:17) at listeners.(anonymous function).forEach.listener (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\safe-emitter.js:45:58) at Array.forEach (<anonymous>) at Object.emit (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\safe-emitter.js:45:38) at NodeEventGenerator.applySelector (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\node-event-generator.js:254:26) at NodeEventGenerator.applySelectors (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\node-event-generator.js:283:22) at NodeEventGenerator.enterNode (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\node-event-generator.js:297:14) at CodePathAnalyzer.enterNode (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:634:23) at nodeQueue.forEach.traversalInfo (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\linter.js:936:32) at Array.forEach (<anonymous>) at runRules (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\linter.js:931:15) at Linter._verifyWithoutProcessors (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\linter.js:1157:31) at Linter._verifyWithConfigArray (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\linter.js:1255:21) at Linter.verify (H:\project\web\demo\vue-admin-template\node_modules\eslint\lib\linter\linter.js:1210:25) @ ./src/router/index.js 6:0-41 11:12-17 @ ./src/main.js @ multi (webpack)-dev-server/client?http://192.168.10.37:9528&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js |
babel-eslint版本:10.1.0
解决:
在.eslintrc.js中添加配置,然后重新运行,ok!
1 2 3 4 5 |
rules : { "indent": ["error", 2, { "ignoredNodes": ["TemplateLiteral"] }] } |