首先说下我是全局引入的Element UI组件
这是要更改message 的默认的时长
重写message的方法
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 全局设置 elementUI的$message的默认显示时间
const messages = ['success', 'warning', 'info', 'error'];
messages.forEach(type => {
ElementUI.Message[type] = options => {
if (typeof options === 'string') {
options = {
message: options
};
// 默认配置
options.duration = 1000;
options.showClose = true;
}
options.type = type;
return ElementUI.Message(options);
}
})
Vue.use(ElementUI)