无效字符 IE 11
Invalid Character IE 11
在 IE 11 和 IE 10 中,我在以下行中遇到无效字符错误:
if (!plugin.$element.attr(``data-${ pluginName }``)) {
我知道这是因为不支持 ES6,但我不知道该如何解决。 Foundation 已经包含了 babel,我认为下面的这个脚本可以解决这个问题,但没有。
return gulp.src(PATHS.javascript)
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.concat('foundation.js', {
newLine:'\n;'
}))
.pipe($.if(isProduction, uglify))
.pipe($.if(!isProduction, $.sourcemaps.write()))
.pipe(gulp.dest('assets/javascript'))
.pipe(browserSync.stream());
});
这是 Foundation 附带的 foundation.core.js 文件中的一个问题。
要查看此问题,您可以导航至下方 url 并在 IE 11 或 10 中加载它:
http://b20.2c7.mwp.accessdomain.com/
有人解决这个问题吗?
我很生气这得到了反对票,因为这是一个实际问题..
基金会应该为我做这件事..
我通过重新安装 Bower 解决了这个问题,它工作正常..奇怪..
Internet Explorer 11 不支持部分 ES6 功能。除了这些不受支持的还有 模板文字 .
见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
为了兼容性。
最好的方法是使用 babel 及其插件来转换模板文字。
安装babel插件
npm install --save-dev babel-plugin-transform-es2015-template-literals
在插件部分的 .babelrc 中添加它
// without options
{
"plugins": ["transform-es2015-template-literals"]
}
// with options
{
"plugins": [
["transform-es2015-template-literals", {
"loose": true,
"spec": true
}]
]
}
IN gulpfile.babel.js,确保所有内容都通过 babel-loader 解析,因此可能注释掉通过 babel-loader 解析的排除文件(其中大部分与基础相关)
所以像这个例子中的文字:
`foo${bar}`;
会变成这样:
"foo" + bar;
查看更多:https://www.npmjs.com/package/babel-plugin-transform-es2015-template-literals
在 IE 11 和 IE 10 中,我在以下行中遇到无效字符错误:
if (!plugin.$element.attr(``data-${ pluginName }``)) {
我知道这是因为不支持 ES6,但我不知道该如何解决。 Foundation 已经包含了 babel,我认为下面的这个脚本可以解决这个问题,但没有。
return gulp.src(PATHS.javascript)
.pipe($.sourcemaps.init())
.pipe($.babel())
.pipe($.concat('foundation.js', {
newLine:'\n;'
}))
.pipe($.if(isProduction, uglify))
.pipe($.if(!isProduction, $.sourcemaps.write()))
.pipe(gulp.dest('assets/javascript'))
.pipe(browserSync.stream());
});
这是 Foundation 附带的 foundation.core.js 文件中的一个问题。
要查看此问题,您可以导航至下方 url 并在 IE 11 或 10 中加载它: http://b20.2c7.mwp.accessdomain.com/
有人解决这个问题吗?
我很生气这得到了反对票,因为这是一个实际问题..
基金会应该为我做这件事..
我通过重新安装 Bower 解决了这个问题,它工作正常..奇怪..
Internet Explorer 11 不支持部分 ES6 功能。除了这些不受支持的还有 模板文字 .
见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals 为了兼容性。
最好的方法是使用 babel 及其插件来转换模板文字。
安装babel插件
npm install --save-dev babel-plugin-transform-es2015-template-literals
在插件部分的 .babelrc 中添加它
// without options
{
"plugins": ["transform-es2015-template-literals"]
}
// with options
{
"plugins": [
["transform-es2015-template-literals", {
"loose": true,
"spec": true
}]
]
}
IN gulpfile.babel.js,确保所有内容都通过 babel-loader 解析,因此可能注释掉通过 babel-loader 解析的排除文件(其中大部分与基础相关)
所以像这个例子中的文字:
`foo${bar}`;
会变成这样:
"foo" + bar;
查看更多:https://www.npmjs.com/package/babel-plugin-transform-es2015-template-literals