Jade报错:Invalid indentation,you can use tabs or spaces but not both问题

来源:互联网 发布:nginx 外网代理 编辑:程序博客网 时间:2024/05/21 11:04

现象:通过html生成jade文件之后,更改jade文件时,语句没什么问题的情况下,jade文件编译不通过,报错:Invalid indentation,you can use tabs or spaces but not both。

原因:错误信息上已经写得很清楚了,是因为jade文件里出现了多余的空格导致文件编译不通过。

解决方法:在代码编辑器中设置tab替换空格,就ok了。本人用的webstorm,在webstorm中设置方法如下:preference->Code Style->jade->Tabs and Indents->勾选Use Tab charactor。就可以了。

然后,点 view->Active Editor->Show Whitespaces,这样就很方便地查看哪里的空格有问题了。或者直接在preference里面设置:preference->Editor->Appearance->勾选Show whitespaces

PS:

有时候报错信息不准确的,虽然报的是A.jade文件的错误,但是不是A文件有问题,而是B文件有问题。大家智取吧。