Coder Social home page Coder Social logo

vue-yp-http's Introduction

VUE-YP-HTTP

基于axios使用在vue上的HTTP组件,根据YP业务二次封装。

Installing

Using yarn:

$ yarn add vue-yp-http

Example

Use in Vue

    import YpHttp from 'vue-yp-http';

    Vue.use(YpHttp, {
        method: '$yphttp', // custom invoke method name, default $http, recommended use default value
        path: '/api', // set global request path
    });


    // in vue scope
    ...
    
    this.$
    
    ...


Performing a POST request, $http.post(method, {params}, {options})

    // method, biz_method
    // params,biz_content
    this.$http.post(method, {params})
        .then(resp=>{
            console.log(resp.data);
        }).catch(err=>{
            console.log(err);        
        });

Performing a UPLOAD POST request, $http.upload({params}, {options})

    this.$http.upload({
        method: '', // biz_method
        UploadFile: ''
    }).then(resp=>{
        console.log(resp.data);
    }).catch(err=>{
        console.log(err);        
    });

Performing a DOWNLOAD POST request, $http.download(method,{params}, {options})

    this.$http.download(
        method, // biz_method
        params, // biz_content
    ).then(resp=>{
            console.log(resp.data);
        }).catch(err=>{
            console.log(err);        
        });

Performing a DOWNLOADFILE POST request, $http.downloadFile(method,{params}), use post method to submit a form, than download a file

    this.$http.downloadFile(
        method, // biz_method
        params, // biz_content
    )

vue-yp-http's People

Contributors

pandajk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.