关于vue的 axios添加token头

关于vue的 axios添加token头

不都说了直接上主题

 this.token = localStorage.getItem('token')
 this.$ajax.defaults.headers['token'] = this.token
 //这样生效但是我开始看文档是这样写的
 this.$ajax
        .post(
          'http://132.232.221.66:8080/api/common/upload/photo', formdata1,
          this.$qs.stringify({
            headers: {'token': this.token}
          }
          )
        )
        //这样写老是不行我看文档查资料这要才是正规的啊为什么?

你可能感兴趣的:(关于vue的 axios添加token头)