Javascript 对象没有';t支持属性或方法';对于';
我在我的一个项目中使用Next JS,在Internet Explorer 11中遇到错误: 对象不支持“for”的属性或方法 该错误似乎源于Javascript 对象没有';t支持属性或方法';对于';,javascript,reactjs,internet-explorer,webpack,next.js,Javascript,Reactjs,Internet Explorer,Webpack,Next.js,我在我的一个项目中使用Next JS,在Internet Explorer 11中遇到错误: 对象不支持“for”的属性或方法 该错误似乎源于commons或webpack文件,请参阅以下隐藏站点的堆栈: 在查看文件中可能使用的方法后,对于方法,似乎是针对捆绑代码中使用的一些符号 我曾尝试在我的网页配置中导入core jspolyfils,如下所示: import 'core-js/features/symbol'; 但这会抛出以下错误: 未捕获错误TypeError:应为对象 我尝试了另一
commons
或webpack
文件,请参阅以下隐藏站点的堆栈:
在查看文件中可能使用的方法后,对于
方法,似乎是针对捆绑代码中使用的一些符号
我曾尝试在我的网页配置中导入core js
polyfils,如下所示:
import 'core-js/features/symbol';
但这会抛出以下错误:
未捕获错误TypeError:应为对象
我尝试了另一种方法-在我的应用程序中包括polyfil
:
我创建了一个next.js应用程序,并在我的代码中使用了
Symbol.for
,它在IE11中运行良好,没有任何错误。你能不能提供一些资料,以便我们双方进行测试?此外,我发现如何添加多边形填充,您可以参考它。而next.js的最新版本是9,你应该尝试使用next.js.yep的最新版本-这就是我遵循的示例…你能提供一个简单的示例或复制步骤吗?因为只有上述信息无法复制该问题。我感谢你的理解。
<script src='https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.23.0/polyfill.min.js' />
require('dotenv').config()
const webpack = require('webpack')
const withSass = require('@zeit/next-sass');
const withFonts = require('next-fonts');
module.exports =
withFonts(withSass({
webpack: (config, {
dev
}) => {
// Fixes npm packages that depend on `fs` module
config.node = {
fs: 'empty'
}
config.plugins.push(new webpack.EnvironmentPlugin(process.env))
if (dev) {
config.devtool = 'cheap-module-source-map';
}
config.module.rules.push({
test: /\.(png|svg)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
publicPath: './',
outputPath: 'static/',
name: '[name].[ext]'
}
}
})
const originalEntry = config.entry
config.entry = async () => {
const entries = await originalEntry()
if (
entries['main.js'] &&
!entries['main.js'].includes('./client/polyfills.js')
) {
entries['main.js'].unshift('./client/polyfills.js')
}
return entries
}
return config
}
}))