亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

vue中this.$http.post()跨域和請求參數(shù)丟失的解決

 更新時間:2022年04月08日 09:33:52   作者:hanq2016  
這篇文章主要介紹了vue中this.$http.post()跨域和請求參數(shù)丟失的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

this.$http.post()跨域和請求參數(shù)丟失

methods: {
    research: function () {
        //post請求遠程資源
        this.$http.post(
            //請求的url
            "http://www.hefeixyh.com/login.html",
            //請求參數(shù),不能以get請求方式寫:{params: {userName: "root123", passWord: "root123"}}
            {userName: "root123", passWord: "root123"},
            //解決跨域問題,不加無法跨域
            {emulateJSON: true}
        ).then(
            function (res) {
                console.log(res);
                this.msg = res.bodyText;
            },
            function (res) {
                console.log(res.status);
            }
        );
    }
}

this.http.post()參數(shù)需注意

第一個參數(shù)是url,第二個參數(shù)是body,body為object,如果body為空的時候,參數(shù)填{};

this.http.post('url' + id, {})

.subscribe(res => {
}, error => {
})

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論