还是有问题,不过现在后端可以正常收到username和password
This commit is contained in:
parent
d5611562e6
commit
1452208822
@ -2,11 +2,19 @@ import axios from "axios";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
login(username, password, apiUrl="http://localhost:8080"){
|
login(username, password, apiUrl="http://localhost:8080"){
|
||||||
return axios.get(`/checkLogin`, {username:username, password:password})
|
const url = `${apiUrl}/users/checkLogin`
|
||||||
|
const data = {
|
||||||
|
username: username,
|
||||||
|
password: password
|
||||||
|
};
|
||||||
|
return axios.post(url, data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
alert("hahaha");
|
alert(">login方法中<");
|
||||||
// 处理登录成功的逻辑
|
alert(response.data);
|
||||||
return response.data;
|
return response.data;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
register(){
|
||||||
|
//跳转逻辑
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,7 @@
|
|||||||
<el-input v-model="username" placeholder="pls enter the username"></el-input>
|
<el-input v-model="username" placeholder="pls enter the username"></el-input>
|
||||||
<el-input v-model="password" placeholder="pls enter the password"></el-input>
|
<el-input v-model="password" placeholder="pls enter the password"></el-input>
|
||||||
<el-button type="success" @click="handleLogin">LOGIN</el-button>
|
<el-button type="success" @click="handleLogin">LOGIN</el-button>
|
||||||
|
<el-button type="success" @click="handleRegister">REGISTER</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -22,6 +23,11 @@
|
|||||||
},methods:{
|
},methods:{
|
||||||
handleLogin(){
|
handleLogin(){
|
||||||
authenticationService.login(this.username,this.password).then(res=>{
|
authenticationService.login(this.username,this.password).then(res=>{
|
||||||
|
alert("login方法调用完毕");
|
||||||
|
alert(res.data);
|
||||||
|
});
|
||||||
|
},handleRegister(){
|
||||||
|
authenticationService.register(this.username,this.password).then(res=>{
|
||||||
alert(res);
|
alert(res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user