el-upload和axios设置header

el-upload加header

<template>
    <el-upload action="test" :headers="myHeaders"></el-upload>
</template>

<script>
var token =  localStorage.getItem('token') // 要保证取到

export default {
    data () {
        return {
            myHeaders: {Authorization: token}
        }
    }
}
</script>

axios加header

    this.axios({
        method: "POST",
        url: `${API_HOST}/api/bind/index`,
        data: obj,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }).then(function(res) {
        console.log(res);
    });

 

posted @ 2021-05-10 10:19  ZJTL  阅读(990)  评论(0编辑  收藏  举报