axios无法发送header

                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

阅读 288
评论
    4 个回答

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

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

    希望可以帮到你