Просмотр исходного кода

修复调用element-ui的Message的方法失败的问题

任一存 4 лет назад
Родитель
Сommit
e2130feb29
2 измененных файлов с 26 добавлено и 4 удалено
  1. 24 2
      src/mixins/index.js
  2. 2 2
      src/utils/request.js

+ 24 - 2
src/mixins/index.js

@@ -51,8 +51,30 @@ Vue.prototype.$msg = (data)=>{
     ...data
   });
 }
-
-
+Vue.prototype.$msg.success = (string)=>{
+  return Message.success({
+    offset:100,
+    message: string
+  });
+}
+Vue.prototype.$msg.warning = (string)=>{
+  return Message.warning({
+    offset:100,
+    message: string
+  });
+}
+Vue.prototype.$msg.message = (string)=>{
+  return Message.message({
+    offset:100,
+    message: string
+  });
+}
+Vue.prototype.$msg.error = (string)=>{
+  return Message.error({
+    offset:100,
+    message: string
+  });
+}
 
 Vue.prototype.$videoImg =
   "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto";

+ 2 - 2
src/utils/request.js

@@ -217,7 +217,7 @@ export const http = {
     }
 
     xhr.done((result) => {
-      if (typeof result.code !== "undefined") {
+      if (typeof result.code !== "undefined") { 
         const flag = statusCodesHandler(result, function(code) {
           // 需要登录的状态
           if (code == statusCode.FAILURE_CODE_5001) {
@@ -236,7 +236,7 @@ export const http = {
           return;
         }
 
-        if (flag === statusCode.FILE) {
+        if (flag === statusCode.FILE) { // 并没有这个值
           done(result);
         }