鍍金池/ 問答/HTML/ vue項(xiàng)目中用了axios的get請(qǐng)求,返回的狀態(tài)碼是200,瀏覽器有數(shù)據(jù),但是

vue項(xiàng)目中用了axios的get請(qǐng)求,返回的狀態(tài)碼是200,瀏覽器有數(shù)據(jù),但是怎樣獲???

在vue項(xiàng)目中,用的是axios的get方法請(qǐng)求 金山詞霸每日一句api
返回的狀態(tài)碼是200,而且有響應(yīng)數(shù)據(jù),如圖:

clipboard.png

clipboard.png

但是瀏覽器卻報(bào)跨越攔截,如圖:

clipboard.png

然后index.js文件中dev的設(shè)置:

proxyTable: {
      '/api':{
        target:"https://open.iciba.com/",
        changeOrigin:true,
        pathRewrite: {'^/api' : '/'}
      }
    },

接著是組件Cart.vue的部分代碼:

// 放在mounted函數(shù)里的 axios 攔截器
// request 
this.$axios.interceptors.request.use((config)=>{
    config.withCredentials = true;
    console.log("request init...");
    console.log(config)
    config.headers={
        "Content-Type":"application/x-www-form-urlencoded"
    }
    return config;
})
// response 
this.$axios.interceptors.response.use((response)=>{
    console.log("response init...");
    console.log(response);
    return response;
})
// axios的get請(qǐng)求
methods: {
        get(){
            var me = this;
            var date =  new Date();
            var year = date.getFullYear() + '-';
            var month = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() +1) + '-';
            var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
            var now = year+month+day;
                
            me.$axios.get('/dsapi',{
                params:{
                    date:now // 年-月-日
                }
            }).then(res=>{
                console.log(res)
            })
        },
}

這是怎么回事,瀏覽器的network查看得到數(shù)據(jù),卻無法獲取,求解決方法

回答
編輯回答
司令

就是跨域了, 前端可以用jsonp請(qǐng)求

import jsonp from 'jsonp';

jsonp('https://open.iciba.com/dsapi/?date=2018-07-11', null, (err, data) => {
  console.log(data)
});
2018年7月11日 21:02