我正在将Vuejs用于我的Web项目。由于有些用户仍在使用IE11,因此我需要使该Web项目兼容。
当前,我在IE11上收到此错误:
SCRIPT5022:引发了异常且未捕获
/***/ "./node_modules/core-js/internals/internal-state.js":
/*!**********************************************************!*\
!*** ./node_modules/core-js/internals/internal-state.js ***!
\**********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var NATIVE_WEAK_MAP = __webpack_require__(/*! ../internals/native-weak-map */ "./node_modules/core-js/internals/native-weak-map.js");
var global = __webpack_require__(/*! ../internals/global */ "./node_modules/core-js/internals/global.js");
var isObject = __webpack_require__(/*! ../internals/is-object */ "./node_modules/core-js/internals/is-object.js");
var createNonEnumerableProperty = __webpack_require__(/*! ../internals/create-non-enumerable-property */ "./node_modules/core-js/internals/create-non-enumerable-property.js");
var objectHas = __webpack_require__(/*! ../internals/has */ "./node_modules/core-js/internals/has.js");
var sharedKey = __webpack_require__(/*! ../internals/shared-key */ "./node_modules/core-js/internals/shared-key.js");
var hiddenKeys = __webpack_require__(/*! ../internals/hidden-keys */ "./node_modules/core-js/internals/hidden-keys.js");
var WeakMap = global.WeakMap;
var set, get, has;
var enforce = function enforce(it) {
return has(it) ? get(it) : set(it, {});
};
var getterFor = function getterFor(TYPE) {
return function (it) {
var state;
if (!isObject(it) || (state = get(it)).type !== TYPE) {
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
}
return state;
};
};
故障线是
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
我希望通过使用填充填充来避免错误行为。
这是webpack.mix.js
const {EnvironmentPlugin} = require ('webpack');
const mix = require ('laravel-mix');
const glob = require ('glob');
const path = require ('path');
const {CleanWebpackPlugin} = require ('clean-webpack-plugin');
const ChunkRenamePlugin = require ('webpack-chunk-rename-plugin');
require ('laravel-mix-tailwind');
require ('laravel-mix-purgecss');
require('laravel-mix-polyfill');
mix.webpackConfig ({
output: {
chunkFilename: 'js/chunks/[name].[chunkhash].js'
},
plugins: [
new CleanWebpackPlugin ({
cleanOnceBeforeBuildPatterns: ['chunks/**/*']
}),
new EnvironmentPlugin ({
BASE_URL: '/'
}),
new ChunkRenamePlugin ({
initialChunksWithEntry: true,
'/js/app': 'js/main.js',
'/js/vendor': 'js/vendor.js',
}),
],
module: {
rules: [
{
test: /node_modules(?:\/|\\).+\.js$/,
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {targets: 'last 2 versions, ie >= 10'}]],
plugins: ['@babel/plugin-transform-destructuring', '@babel/plugin-proposal-object-rest-spread', '@babel/plugin-transform-template-literals'],
babelrc: false
}
},
{
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
]
},
resolve: {
alias: {
'@': path.join (__dirname, 'resources'),
'node_modules': path.join (__dirname, 'node_modules')
}
},
});
mix.js ('resources/js/main.js', 'public/js')
.postCss ('resources/css/app.css', 'public/css')
.tailwind ('./tailwind.config.js')
.polyfill({
enabled: true,
useBuiltIns: "entry",
targets: "> 0.25%, not dead"
})
有什么办法可以解决这个问题吗?
答案 0 :(得分:0)
我知道现在回复有点晚了。我最近遇到了同样的问题。我是这样解决的:
异常中的消息是判断是否是任何 API 问题的关键。在这种情况下,我遇到了符号。
If you want to see the message in console, you can click here
我正在努力使用 core-js 添加 polyfill,但错误仍然存在。我使用了 https://polyfill.io 中的 polyfill,一切正常。
我把脚本放在 index.html 的头部,一切都很好。
<script crossorigin="anonymous" src="https://polyfill.io/v3/polyfill.min.js?features=fetch%2Cdefault"></script>
babel 配置我只将预设和插件添加为字符串,我没有配置任何其他内容。而在 webpack.config 我只添加了 babel-loader
{
"presets": [
"@babel/preset-react",
"@babel/preset-env"
],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
如果您有任何问题,我很细心。谢谢你,我希望这个回复能让你对可能发生的事情有所了解。
您好!