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.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;
});

推荐答案

0

已采纳

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

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

希望可以帮到你

推广链接