当我们在运行ionic serve命令启动项目的时候,有时候会报Cannot read property 'substr' of undefined这种错误:

error.png

错误原因:这个其实是source-node.js中的一个bug,当我们的一个Component文件中定义了2个以上的类的时候,就会出现这种报错。

解决方法:

方法1、尽量一个Component文件中只定义一个类。

方法2、修改node_modules\webpack-sources\node_modules\source-map\lib\source-map\source-node.js,找到这句话(出现2次)

var nextLine = remainingLines[0];

改成这样

var nextLine = remainingLines[0] || '';




上一篇:Ionic组件之Loading

下一篇:Ionic组件之Modals