【发布时间】:2017-05-11 23:48:16
【问题描述】:
当我尝试将以下代码保存在 sublime text 中时,
'use strict';
/*global angular,_*/
var app = angular.module("myApp", []);
app.controller("myCtrl", function ($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
我收到以下 jslint 错误:
#1 Unexpected expression 'use strict' in statement position.
'use strict'; // Line 1, Pos 1
#2 Place the '/*global*/' directive before the first statement.
/*global angular,_*/ // Line 2, Pos 1
#3 Undeclared 'angular'.
var app = angular.module("myApp", []); // Line 4, Pos 11
#4 Expected 'use strict' before '$scope'.
$scope.firstName = "John"; // Line 6, Pos 3
#5 Expected '$scope' at column 5, not column 3.
$scope.lastName = "Doe"; // Line 7, Pos 3
【问题讨论】:
-
我已经检查了该链接 @TheSharpieOne 。这不符合我的目的。
-
So.. 答案的一部分说“根据the documentation,JSLint 的浏览器选项会自动禁用“使用严格”;在全局级别。就我而言请注意,没有办法重新打开它。”没有帮助您意识到您不能将
'use strict';放在那里并且放在那里有问题吗? -
如果 'use strict' 没有被使用,那么 jslint 错误仍然存在,说“预期 'use strict' 在 '$scope' 之前”
标签: javascript angularjs jslint