我使用Vuetify和vue-axios创建一个项目,并创建一个简单的登录组件,但是我有问题要获取Vue实例
这是我的登录组件:
<template>
<v-app id="inspire">
<v-content>
<v-container fluid fill-height>
<v-layout align-center justify-center>
<v-flex xs12 sm8 md4>
<v-card class="elevation-12">
<v-toolbar dark color="primary">
...
</v-toolbar>
<v-card-text>
...
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" @click='logar()'>Entrar</v-btn>
</v-card-actions>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-content>
</v-app>
</template>
<script>
export default {
name: 'Login',
data: () => ({
drawer: null,
checkbox: false,
username: 'cartorio@teste.com.br',
password: '1234',
}),
props: {
source: String,
},
methods: {
logar() {
var myVue = this.$vuetify;
this.axios.post('http://localhost:8585/login', {
email: this.username,
senha: this.password,
},
{
withCredentials: false,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
},
).then((response) => {
//HERE I NEED TO USE myVue
window.AUT = response.headers.authorization;
}).catch((error) => {
console.log(error);
});
},
},
};
</script>
所以,在axios promisse中,那么我需要使用我的var myVue,那么为什么总是得到未定义?
tks