|
@@ -150,6 +150,35 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
// Vue.use(ElementUI, { locale })
|
|
|
// 如果想要中文版 element-ui,按如下方式声明
|
|
|
Vue.use(ElementUI)
|
|
|
+
|
|
|
+import { Message } from 'element-ui';
|
|
|
+//定义一个新的Message方法,多传入一个offset参数
|
|
|
+const $message = options => {
|
|
|
+ return Message({
|
|
|
+ ...options,
|
|
|
+ offset: 80
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+//重写方法,将offset写入options
|
|
|
+['success', 'warning', 'info', 'error'].forEach(type => {
|
|
|
+ $message[type] = options => {
|
|
|
+ if (typeof options === 'string') {
|
|
|
+ options = {
|
|
|
+ message: options,
|
|
|
+ offset: 80
|
|
|
+ };
|
|
|
+ }
|
|
|
+ options.type = type;
|
|
|
+ return Message(options);
|
|
|
+ };
|
|
|
+});
|
|
|
+//将$message挂载到this上
|
|
|
+Vue.prototype.$message = $message;
|
|
|
+//不加这行代码运行this.$message.closeAll时会报错
|
|
|
+Vue.prototype.$message.closeAll = Message.closeAll;
|
|
|
+
|
|
|
+
|
|
|
// register global utility filters
|
|
|
Object.keys(filters).forEach(key => {
|
|
|
Vue.filter(key, filters[key])
|