search

Home  >  Q&A  >  body text

javascript - How to request real data from the background when using vue-cli for projects?

How to request real data from the background when using vue-cli for projects?

世界只因有你世界只因有你2790 days ago762

reply all(5)I'll reply

  • 高洛峰

    高洛峰2017-05-19 10:38:41

    Didn’t the backend open an interface for you?

    reply
    0
  • PHPz

    PHPz2017-05-19 10:38:41

    You can use vue-resource

    //get || post
    this.$http.get(url).then((res) => {
        // do something
    }, (res) => {
        // error callback
    })

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:38:41

    You can use vue-resource to make requests
    Maybe the poster is encountering a cross-domain problem?
    If the background is php, please add it to the receiving method

    header('Access-Control-Allow-Credentials:true');
    header("Access-Control-Allow-Origin:*");
    header('Access-Control-Allow-Headers:x-requested-with,content-type');

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-19 10:38:41

    axios,jquery

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-19 10:38:41

    What the original poster means is how to request back-end data, not that there is no interface. Just configure a proxy. There is no need to cross domain. Just configure a proxyTable in index.js under config.

    reply
    0
  • Cancelreply