0
                axios.post(this.url + 'vdata_cate/getVdataCate', {
                    params: {
                        id: 3,
                        name: 'abc'
                    },
                    headers: {
                        'token': '123123213123'
                    }
                }).then((response) => {

                    console.log(response.data);

                    this.data1 = response.data.r;
                    this.totalnumber = response.data.totalnumber;
                });

image.png

12月3日提问
4 个回答
0

已采纳

你好,axios 添加 headers 要在请求前添加,你可以在拦截器中这么写:

axios.interceptors.request.use(config => {
    if (token) {
        config.headers.common['Authorization'] = token
    }
    }

希望可以帮到你

0

你的请求是post请求,用params传参干啥,headers写错地方了

0

建议仔细查看axios官方文档

0
axios.post(this.url + 'vdata_cate/getVdataCate', {
    id: 3, name: 'abc'
}, {
    headers: { 'token': '123123213123' }
}).then((response) => {
    this.data1 = response.data.r;
    this.totalnumber = response.data.totalnumber;
});

撰写答案

推广链接