前端怎么将 固定好的token值放到请求头再发送请求 我这样写好像不对

放到请求拦截里 。你这样 只是post的加上了
类似于这样
https://www.axios-http.cn/docs/interceptors
axios.interceptors.request.use(
config => {
if (localStorage.getItem('token')) {
// 如果后台要token这么写:
config.headers.token = localStorage.getItem('token')
// 如果后台要Authorization 这么写:config.headers.Authorization = `Bearer ` + localStorage.getItem('token')
}
return config
},
error =>{
return Promise.reject(error)
}
)
或者 axios全局 配置
