码迷,mamicode.com
首页 > 移动开发 > 详细

Vue axios发送Http请求

时间:2018-06-09 22:11:13      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:lan   script   ret   http   vue   style   请求   rom   class   

axios

  1.cnpm install axios --save
  2.在vue文件中引入,import Axios from ‘axios‘
  3.使用,Axios.get(url).then((res)=>{}).catch((err)=>{})

<template>
  <div id="app">
    <div v-html="htmlValue"></div>
  </div>
</template>

<script>
import Axios from "axios";
export default {
  name: "app",
  data() {
    return {
      flag: true,
      htmlValue: ""
    };
  },
  methods: {
    getData() {
      Axios.post(`http://api2.cpf360.com/api/auth/login`)
        .then(res => {
          console.log(res)
          this.htmlValue=res.data
        })
        .catch(err => {});
    }
  },
  mounted() {
    this.getData();
  }
};
</script>

<style lang="scss">
</style>

 

Vue axios发送Http请求

标签:lan   script   ret   http   vue   style   请求   rom   class   

原文地址:https://www.cnblogs.com/chenyishi/p/9160776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!