在IE 9中构建AngularJS项目(使用默认的grunt uglification和minification设置进行测试)时出现此错误:
Script1014:无效字符
在两个不同的项目中,行和字符始终指示第一个
中冒号后面的字符:"A",
在缩小/丑化的供应商javascript中。
bower.json依赖项:
"dependencies": {
"angular": "1.2.6",
"json3": "~3.2.6",
"es5-shim": "~2.1.0",
"jquery": "~1.10.2",
"bootstrap": "~3.0.3",
"angular-resource": "1.2.6",
"angular-cookies": "1.2.6",
"angular-sanitize": "1.2.6",
"angular-route": "1.2.6",
"moment": "~2.5.0",
"ngInfiniteScroll": "1.0.0",
"angular-ui": "~0.4.0",
"angular-bootstrap": "~0.10.0",
"components-font-awesome": "~4.0.3",
"select2": "~3.4.5",
"angular-animate": "1.2.6"
},
index.html供应商js:
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/moment/moment.js"></script>
<script src="bower_components/ngInfiniteScroll/ng-infinite-scroll.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/select2/select2.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-mocks/angular-mocks.js"></script>
<!-- endbower -->
<script src="bower_components/angular-ui/build/angular-ui.js"></script>
<!-- endbuild -->
知道可能导致问题的原因或调试此问题的最佳方法吗?非常感谢任何帮助!
答案 0 :(得分:3)
这是IE中unicode支持的已知问题的结果。
要避免此问题,可以将ascii_only: true
选项传递给Gruntfile.js中的uglify任务。完整的uglify部分可能如下所示:
uglify: {
options: {
beautify: {
ascii_only: true,
quote_keys: true,
beautify: false
},
preserveComments: false,
compress: false,
mangle: false
},
dist: {
files: {
'<%= yeoman.dist %>/scripts/scripts.js': [
'<%= yeoman.dist %>/scripts/scripts.js'
]
}
}
}
有关这些选项的详细信息,请参阅UglifyJS API docs。
答案 1 :(得分:0)
有时IE在您没有HTTP服务器的情况下运行您的网站时不喜欢并且可能导致此错误。您是在运行任何网络服务器还是直接在浏览器中打开HTML?
如果没有网络服务器运行,你可以尝试在网络服务器上运行它。