javascript - vue-resource中使用jsonp,参数不全
伊谢尔伦
伊谢尔伦 2017-04-11 11:27:13
[JavaScript讨论组]

使用vue+vue-resource发送jsonp请求:

var jsonStr = {
                "userId":"",
                "type":this.type,
                "name":this.searchContent,
                "itId" : this.itId,
                "regionid" : this.regionid=="0"?"":this.regionid,
                "pageNow":this.pageNum,
                "sort":"",
                "pageCount":"10",
                "auditstatus":"2"
            };
            jsonStr = JSON.stringify(jsonStr);
            var sendData = {
                marked : "helpList",
                jsonStr : jsonStr
            };
            var that = this;

/*            var _fnCallback_needmarket = function(data) {
                //window.demo.h5Log(JSON.stringify(data)); 
                that.helpList = that.helpList.concat(data.helpList);
            };*/

            console.log(sendData);

            this.$http.jsonp(Util.url,{
                params : sendData
            }).then((response) => {
                // success callback
                that.helpList = that.helpList.concat(response.helpList);
            }, (response) => {
                // error callback
            });

发送之前console.log了一下,sendData的值是

但是发送请求的时候,看请求里,参数不全,如下

没有了mark字段和callback字段。谁能告诉我下为什么?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
怪我咯

我也遇到了这个问题,在jsonp里请求参数,除了{jsonp:"back"}起作用,其他不管什么参或者把jsonp的key改成什么都不起作用!
Vue.http.jsonp(DEV_HOST+'/benefitlist',{pageID:29,jsonp:"_callback"})
Vue.http.jsonp(DEV_HOST+'/benefitlist',{pageID:29},{jsonp:"_callback"})

已经解决 | 添加代码:
Vue.http.jsonp(DEV_HOST+'/benefitlist',{params: {pageID:29},jsonp:"_callback"})

亲测,params是固定key,把params改成其他的都不行!

大家讲道理

我也遇到了类似的情况。我发送的参数在接口实际发送时丢失了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号