由于目前没有发现axios可以同步请求,所以只能使用jQuery

vue 安装jQuery插件:

$ npm install jquery --save

在程序中引入$

import $ from 'jquery';

具体代码

 $.ajax({
            url:'',//url路径
            type:'POST', //GET
            async:false, //或false,是否异步
            data:{//参数
               
            },
            timeout:5000, //超时时间
            dataType:'json', //返回的数据格式:
            beforeSend:function(xhr){
            },
            success:function(data,textStatus,jqXHR){
               
            },
            error:function(xhr,textStatus){
                console.log('小程序cookie获取失败---->'+textStatus);
            },
            complete:function(){
            }
       })

 

Logo

前往低代码交流专区

更多推荐