gpt4 book ai didi

javascript - 缩小 angularjs 应用程序时出现错误 : Unexpected token punc «)», 预期的 punc «,»

转载 作者:行者123 更新时间:2023-11-28 18:55:56 24 4
gpt4 key购买 nike

我正在尝试缩小我的 app.js 代码(尝试了几种在线工具)。但我得到了问题中提到的错误。这是我的代码:

(function() {
var app = angular.module('LazyApp', []);
app.directive('lazyLoad', ['$window', function($window) {
return {
restrict: 'A',
scope : {},
link: function(scope, element, attrs) {
var images = Array.prototype.slice.call(element[0].querySelectorAll("img[data-src]"));
var videos = Array.prototype.slice.call(element[0].querySelectorAll("iframe[data-src]"));
}
}
})
}])();

我做错了什么?

最佳答案

我想你想要这个

(function() {
angular.module('LazyApp', [])
.directive('lazyLoad', ['$window', function($window) {
return {
restrict: 'A',
scope : {},
link: function(scope, element) {
var images = Array.prototype.slice.call(element[0].querySelectorAll("img[data-src]"));
var videos = Array.prototype.slice.call(element[0].querySelectorAll("iframe[data-src]"));
}
};
}])
})();

您的指令构造函数的右方括号位于错误的位置。

关于javascript - 缩小 angularjs 应用程序时出现错误 : Unexpected token punc «)», 预期的 punc «,»,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33644152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com