IE报错Error in v-on handler: “TypeError: 对象不支持此操作

IE11中点击el-menu报错Error in v-on handler: "TypeError: 对象不支持此操作

在这里插入图片描述

解决方案

新建一个js文件,在main.js中引入。注意此js引入需在elementui引入之前。
js文件内容入下

/* eslint-disable */
(function(window) {
    try {
        new MouseEvent('test');
        return false; // No need to polyfill
    } catch (e) {
        // Need to polyfill - fall through
    }
    // Polyfills DOM4 MouseEvent
    var MouseEvent = function(eventType, params) {
        params = params || { bubbles: false, cancelable: false };
        var mouseEvent = document.createEvent('MouseEvent');
        mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        return mouseEvent;
    };

    MouseEvent.prototype = Event.prototype;

    window.MouseEvent = MouseEvent;
}(window));

原文参考:https://github.com/ElemeFE/element/issues/17404

猜你喜欢

转载自blog.csdn.net/qq_41839808/article/details/116199500