zoukankan      html  css  js  c++  java
  • Vue vue-resource发送Http请求

    vue-resource

      1.cnpm install vue-resource --save
      2.在main.js中import VueResource from 'vue-resource'
      3.在main.js中Vue.use(VueResource)
      4.在组件中使用this.$http.get(url).then((response)=>{},(err)=>{})

    <template>
      <div id="app">
        <div v-html="htmlValue"></div>
      </div>
    </template>
    
    <script>
    import Home from "./components/Home.vue";
    export default {
      name: "app",
      data() {
        return {
          flag: true,
          htmlValue: ""
        };
      },
      methods: {
        getData() {
          this.$http.post(`http://360.com/api/auth/login`).then(
            res => {
              console.log(res);
              this.htmlValue = res.body;
            },
            err => {}
          );
        }
      },
      mounted(){
        this.getData();
      }
    };
    </script>
    
    <style lang="scss">
    </style>
  • 相关阅读:
    HDU 3068 Manacher
    HDU 6188最小费用流
    Codeforces Round #442 (Div. 2) Danil and a Part-time Job
    并查集
    HDU 5988最小网络流(浮点数)
    HOJ
    HOJ
    POJ
    POJ
    关于async
  • 原文地址:https://www.cnblogs.com/chenyishi/p/9160731.html
Copyright © 2011-2022 走看看