【发布时间】:2014-08-05 16:16:23
【问题描述】:
我正在开发一个使用大量 js 库并且主要使用 Express JS 的应用程序。 所有代码都可以在 Firefox 和 Chrome 上正常运行。但我在 IE8 和 IE9 中遇到错误。
SCRIPT5022: fromText eval for hbs!notification/templates/dropDown failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!notification/templates/dropDownItem failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/templates/teamManagement failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/alarms/templates/projectAlarms failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!admin/templates/navigation failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
SCRIPT5022: fromText eval for hbs!layouts/admin/templates/base failed: SyntaxError: Syntax error in regular expression
http://requirejs.org/docs/errors.html#fromtexteval
require.js, line 138 character 9
这些错误只出现在 IE8 和 IE9 中。
这是我的 config.js
require.config({
paths: {
// Require plugins
'text': 'vendor/requirejs-text/text',
'css': 'vendor/css/css',
'hbs': 'vendor/require-handlebars-plugin/hbs',
'Handlebars': 'vendor/require-handlebars-plugin/Handlebars',
'i18nprecompile': 'vendor/require-handlebars-plugin/i18nprecompile',
'json2': 'vendor/require-handlebars-plugin/json2',
// Libraries
'es5shim': 'vendor/es5-shim/es5-shim',
'underscore': 'vendor/underscore/underscore',
'jquery': 'vendor/jquery/jquery',
'jquery.DatePicker': 'vendor/datepicker/datepicker',
'jquery.mousewheel': 'vendor/jquery-mousewheel/jquery.mousewheel',
'backbone': 'vendor/backbone/backbone',
'backbone.virtualCollection': 'vendor/backbone-virtual-collection/backbone.virtual-collection',
'backbone.marionette': 'vendor/backbone.marionette/backbone.marionette',
'backbone.marionette.handlebars': 'vendor/backbone.marionette.handlebars/backbone.marionette.handlebars',
'leaflet': 'vendor/leaflet/leaflet-src',
'highcharts': 'vendor/highcharts/highcharts.src',
'paper': 'vendor/paper/paper',
'handsontable': 'vendor/handsontable/jquery.handsontable',
'walltime': 'vendor/walltime-js/walltime',
'walltime-data': 'vendor/walltime-js/walltime-data'
},
shim: {
'underscore': {
exports: '_'
},
'jquery.DatePicker': {
deps: ['jquery']
},
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'backbone.marionette': {
deps: ['backbone'],
exports: 'Marionette'
},
'backbone.virtualCollection': {
deps: ['backbone', 'underscore']
},
'leaflet': {
exports: 'L'
},
'highcharts': {
deps: ['jquery'],
exports: 'Highcharts'
},
'walltime': {
deps: ['walltime-data']
}
},
hbs: {
i18nDirectory: 'i18n/',
disableI18n: false, // This disables the i18n helper and
// doesn't require the json i18n files (e.g. en_us.json)
// (false by default)
disableHelpers: true, // When true, won't look for and try to automatically load
// helpers (false by default)
helperPathCallback: // Callback to determine the path to look for helpers
function (name) { // ('/template/helpers/'+name by default)
return 'cs!' + name;
},
compileOptions: {} // options object which is passed to Handlebars compiler
}
});
请帮帮我!
----- 更新 -----
我将此作为问题发布在 Github 上,用于 requirejs 存储库。
你可以找到它here
根据评论,IE9 中的 eval 似乎有问题。
我还尝试将eval("("+text+")") 放在here 中,但仍然没有成功。
谁能告诉我如何让这个 eval 东西在 IE9 中工作。
谢谢
【问题讨论】:
-
尝试在你的 html 中添加这个
-
@Dalorzo:第一条评论无效!!
标签: javascript internet-explorer requirejs