vue resource jsonp請求

vue resource jsonp請求

 window.onload = function () {
        var app = new Vue({
            el: ".box",
            data: {},
            methods: {
                get: function () {
                    this.$http.jsonp('https://sug.so.360.cn/suggest', {
                        params:{
                            word: 'a',
                            encodeout:'utf-8' //防止亂碼
                        }
                    }).then(function (res) {
                        alert(res.data.s);
                        console.log(res.data.s);
                    }, function () {
                        alert('失敗')
                    })
                }
            },
        })
    }

注意點:不要漏了params ;encodeout:'utf-8' 防止中文亂碼

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章