解决 vue axios 带 header 时,会默认发起 OPTIONS 请求的方法的问题

This commit is contained in:
YunaiV
2019-03-27 19:12:12 +08:00
parent 42b11e377e
commit c23eb737f0
10 changed files with 182 additions and 17 deletions

View File

@@ -82,21 +82,32 @@
</template>
<script>
import { GetUserIndex } from "../../api/user.js";
// import { GetUserIndex } from "../../api/user.js";
import { getAccessToken } from '../../utils/cache.js';
import { getUserInfo } from '../../api/user.js';
export default {
data(){
return{
data:{}
data: {},
user: {},
}
},
components: {
},
created:function(){
GetUserIndex().then(response=>{
this.data=response;
});
// GetUserIndex().then(response=>{
// this.data=response;
// });
},
mounted() {
if (getAccessToken()) { // 存在
let response = getUserInfo();
response.then(data => {
this.user = data;
});
}
}
};
</script>