Network Processor Module

    element-ui-ext-jwd

    0.2.30 • Public • Published

    element-ui-ext

    vue element ui extend

    用法

    import Vue from 'vue' import App from './App' import router from './router.js' import axios from 'axios' import ElementUI from 'element-ui/lib/index.js' import ElementUIExt from 'element-ui-ext/lib/main.min' import jv from "libjv"

    (function (jv) { window.jv = jv;

    jv.initApp(Vue.prototype) jv.initAxios(axios);

    /Vue.config.productionTip = false;/ Vue.use(ElementUI); Vue.use(ElementUIExt); Vue.prototype.$http = axios; })(jv);

    (function (jv) { let vue = new Vue({ el: '#app', router, watch: { '$route'(to, from) { } }, render(render) { return render(App); } }); })(jv);

    备注

    原生上传, 现己废弃.

      post(processedFile) {
              var file = processedFile || this.$el.querySelector("input");
    
        const xhr = new XMLHttpRequest();
        let action = this.Upload_Url;
    
        if (this.proxy) {
          action = jv.CorpApi_Host + "/sys/fileUpload";
        }
    
        if (xhr.upload) {
          xhr.upload.onprogress = (e) => {
            if (e.total > 0) {
              e.percent = parseInt(e.loaded / e.total * 90);
            }
            this.percentage = e.percent + 10;
          };
        }
    
        const formData = new FormData();
    
        formData.append(file.name.split("/").last(), file);
    
        xhr.onerror = (e) => {
          this.percentage = 0;
          jv.error(e);
        };
    
        xhr.onload = () => {
          if (xhr.status < 200 || xhr.status >= 300) {
            this.percentage = 0;
            jv.error("上传失败!");
            return;
          }
    
          var getBody = function (xhr) {
            const text = xhr.responseText || xhr.response;
            if (!text) {
              return text;
            }
    
            try {
              return JSON.parse(text);
            } catch (e) {
              return text;
            }
          }
    
          var json = getBody(xhr);
          if (json.msg) {
            this.percentage = 0;
            return jv.error(json.msg);
          }
          this.emit(json);
        };
    
        xhr.open('post', action, true);
        xhr.withCredentials = true;
        if (this.proxy) {
          xhr.setRequestHeader('proxy', jv.Session_Id);
    
          if (this.proxyCorpId) {
            xhr.setRequestHeader('Corp-Id', this.proxyCorpId);
          }
        }
        xhr.send(formData);
        return xhr;
      }
    

    Install

    npm i element-ui-ext-jwd

    DownloadsWeekly Downloads

    2

    Version

    0.2.30

    License

    ISC

    Unpacked Size

    1.73 MB

    Total Files

    17

    Last publish

    Collaborators

    • anke1938