1.创建util.js,内容为(在element ui源码上面进行修改)
import Vue from 'vue'
import ElementUI from 'element-ui';
['success', 'warning', 'info', 'error'].forEach(type => {
ElementUI.Message[type] = options => {
if (typeof options === 'string') {
options = {
message: options
};
if (type == 'warning' || type == 'error') {
options.duration = 6000
options.showClose = true
}
}
options.type = type;
return ElementUI.Message(options);
};
});
2.在main.js内引入
import './utils/utils'