gpt4 book ai didi

javascript - 如何检查缩小是否出错?

转载 作者:行者123 更新时间:2023-11-30 16:06:13 25 4
gpt4 key购买 nike

我的代码中有一个 resolve,它在本地运行得非常好,所有测试也都通过了。然而,缩小代码似乎在这里引起了一些问题。

当我暂存代码然后在本地运行它时,它会导致与缩小代码相同的问题。解析 block 不再做它的工作。

有没有办法将缩小后的代码与实际代码进行比较以找出差异?

.state('index', {
url: '/',
resolve: {
trans: ['resolveService', function(resolveService) {
resolveService.languageResolve('main', {});
}]
},
controller: 'IndexCtrl'
})
.state('main', {
url: '/{language:[a-z]{2}}',
templateUrl: 'app/main/main.html',

controller: 'MainCtrl',
controllerAs: 'mainCtrl',
resolve: {
trans: ['resolveService', '$stateParams', function(resolveService, $stateParams) {
return resolveService.translateResolve($stateParams);
}],
redirect: ['resolveService', function(resolveService) {
return resolveService.resolveRedirect();
}]
}
})
.state('main.results', {
url: '/results/{route:nonURIEncoded}',
templateUrl: 'app/results/results.wrapper.html',
controller: 'ResultsCtrl',
resolve: {
urlParsed: ['urlParser','$stateParams','$state',function(urlParser,$stateParams,$state){
return urlParser.parse($stateParams.route).then(function(){ return true },function(err){
$state.go('main',{
language: $stateParams.language
});
});
}]
},
controllerAs: 'rc'
})

最佳答案

如果您在比较原始代码和缩小后的代码时遇到不同的行为,我很确定缩小过程中出了点问题,导致结果不完整或解析错误。您应该检查您的浏览器控制台和您的缩小器日志是否有错误。

此外,正如评论(12)中已经指出的那样,您可以漂亮地打印缩小的代码以手动检查差异在哪里。

In Chrome :

Pretty Print JavaScript

The DevTools support prettifying of minified JavaScript to a more readable form. To pretty print:

  • Go to the Sources panel and selected your desired script from the scripts list.

  • Next, press the "Pretty print" button (marked with curly braces) from the bottom of the DevTools window.

  • Your code should now be prettified!

Before

before

After

after

关于javascript - 如何检查缩小是否出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36998995/

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