美文网首页
路由引入方式或报错range,解决Cannot read pro

路由引入方式或报错range,解决Cannot read pro

作者: MT659 | 来源:发表于2021-06-24 05:25 被阅读0次

今天将模板项目 npm install 一直报 Cannot read property ‘range’ of null 也是很无奈
多方排查 babel-eslint 高版本 代码检测问题

解决方式

  1. 降低babel-eslint 的版本

  2. 问题所在

  component: () => import(`@/views/modules/${URL}`)

动态路由页面引入方式的一种

Cannot read property 'range' of null

写法违反了返回值null 的限制

不能这么引入我换一种

// 第一种
 component: resolve => require([`@/views/modules/${URL}`], resolve)
// 第二种
 component: r => require.ensure([], () => r(require(`@/views/modules/${URL}`)), `${URL}`)

于是乎就这么可以了

相关文章

网友评论

      本文标题:路由引入方式或报错range,解决Cannot read pro

      本文链接:https://www.haomeiwen.com/subject/wjpyyltx.html