解决 vue axios 带 header 时,会默认发起 OPTIONS 请求的方法的问题
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user