我有一个问题,我没有看到有人遇到这种问题。基本上我做了一个帮助器来格式化日期,它有一些 EcmaScript 的语法,比如 let 或 expoorts。它可以在除 INTERNET EXPLORER 之外的所有浏览器中运行,所以我可以配置 Polyfill,所以我阅读了文档以使用 ember-cli-babel 配置它,但我无法看到预期的结果。
我有一个 ember 应用程序,带有 ember cli
DEBUG: -------------------------------
DEBUG: Ember : 2.14.1
DEBUG: jQuery : 2.2.4
DEBUG: -------------------------------
我在我的花椰菜文件中包含 POLYFILL,就像这个 ember-cli
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
'ember-cli-babel': {
includePolyfill: true
},
storeConfigInMeta: false,
minifyJS: {
enabled: false
},
minifyCSS: {
enabled: false
},
vendorFiles: {
'jquery.js': {
development: 'bower_components/jquery/dist/jquery.js',
production: false,
development: false
}
}
});
app.import('vendor/jquery.lumanetix.all.min.js');
return app.toTree();
};
我有一个灰烬助手来格式化日期,它是:
import Ember from 'ember';
export function dateAuctionFormat(date/*, hash*/) {
let dateObj = new Date(date);
let monthName = getMonthName(dateObj.getUTCMonth());
let dayNumber = dateObj.getUTCDate();
dayNumber = dayNumber + formatDateNotation(dayNumber);
let dayName = getWeekDayName(dateObj.getDay());
let time = dateObj.toLocaleString('en-US', { hour: 'numeric', minute:'numeric', hour12: true });
return dayName + ' ' + dayNumber + ' ' + monthName + ' ' + time;
}
function getMonthName(date) {
let month = [];
month[0] = "Jan";
month[1] = "Feb";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "Aug";
month[8] = "Sept";
month[9] = "Oct";
month[10] = "Nov";
month[11] = "Dec";
return month[date];
}
function getWeekDayName(date) {
let weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
return weekday[date];
}
function formatDateNotation(d) {
if (d > 3 && d < 21) {
return 'th';
}
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
export default Ember.Helper.helper(dateAuctionFormat);
但是当 Internet Explorer 11 渲染站点时,调试器中出现如下错误:
错误说是预期的对象。并且您可以看到该行之后显示的错误
export default App.extend({
// rootElement: '#listings-search'
});
所以我不知道从哪里开始,我尝试修改一点,app.js,但没有运气,我也尝试使用这个转换器将我的 ES6 代码转换为 ES5: https ://babeljs.io/repl/
但当然它没有用,也不是这个想法。