wenbobowen 4 年之前
父节点
当前提交
3e3d352fb4
共有 1 个文件被更改,包括 21 次插入19 次删除
  1. 21 19
      src/components/input/normalArea.vue

+ 21 - 19
src/components/input/normalArea.vue

@@ -141,25 +141,27 @@ export default {
       return newStr
     },
     uploadImg(imgData) {
-      const HTTP = axios.create({
-        baseURL: '/apis', // 这是基础url
-        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
-        transformRequest: [(data) => {
-          // Do whatever you want to transform the data
-          let ret = ''
-          for (const it in data) {
-            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
-          }
-          return ret
-        }]
-      })
-      HTTP.post('//star.xiaojukeji.com/upload/img.node', {
-        'imgData': imgData,
-        'innerPublic': true
-      }).then((res) => {
-        console.log('res', res)
-        console.log('res.url', res.url)
-        return res.url
+      return new Promise((resolve, reject) => {
+        const HTTP = axios.create({
+          baseURL: '/apis', // 这是基础url
+          headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+          transformRequest: [(data) => {
+            // Do whatever you want to transform the data
+            let ret = ''
+            for (const it in data) {
+              ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
+            }
+            return ret
+          }]
+        })
+        HTTP.post('//star.xiaojukeji.com/upload/img.node', {
+          'imgData': imgData,
+          'innerPublic': true
+        }).then((res) => {
+          console.log('res', res)
+          console.log('res.url', res.url)
+          resolve(res.url)
+        })
       })
       // return new Promise((resolve, reject) => {
       //   axios.post(