zoukankan      html  css  js  c++  java
  • Vue之resource请求数据

      导入resource文件

    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>

      代码块:

      1、get请求

    1             var params = {
    2                 locale: "zh"
    3             };
    4             that.$http.get('url',{params:params}).then(function (res) {
    5                 console.log(res);
    6             },function (err) {
    7                 console.log(22222222222);
    8             })        

      2、post请求:post 发送数据到后端,需要第三个参数 {emulateJSON:true}。emulateJSON 的作用: 如果Web服务器无法处理编码为 application/json 的请求,你可以启用 emulateJSON 选项。

      

    1             var params = {
    2                 locale: "zh"
    3             };
    4             that.$http.post('url',params,{emulateJSON:true}).then(function (res) {
    5                 console.log(res);
    6             },function (err) {
    7                 console.log(22222222222);
    8             })    

      API:

      

        

      

  • 相关阅读:
    CoreData
    转场动画
    java基础(8)
    java基础(7)
    java基础(6)
    java基础(5)
    java基础(4)
    java基础(3)
    java基础(2)
    java基础(1)
  • 原文地址:https://www.cnblogs.com/nelsonlei/p/10528596.html
Copyright © 2011-2022 走看看