赞
踩
我采用的接收形式数据是json格式
@PostMapping("/login")
public Resp login(@RequestBody User user){
User login = userService.login(user.getStudentid(),user.getPassword());
return Resp.success(login);
}
@PostMapping("/regist")
public Resp regist(@RequestBody User user){
userService.regist(user);
return Resp.success(null);
}
<body> <div id="app"> <form> 账号:<input type="text" name="studentid" v-model="registform.studentid"><br> 密码:<input type="text" name="password" v-model="registform.password"><br> 用户名:<input type="text" name="username" v-model="registform.username"><br> <input type="button" value="denglu" @click="tologin"> </form> </div> </body> <script type="text/javascript" src="../js/jquery.min.js"></script> <script src="../js/vue.js"></script> <script src="../js/axios-0.18.0.js"></script> <script> var vue = new Vue({ el:"#app", data:{ registform:{ studentid: "12345678", password: "123456", // username:"qwq" } }, methods:{ tologin:function(){ let datata = this.registform; console.log("通了"); axios.post("/user/login",datata).then(function(response){ console.log(response.data); }) } } }) </script>
向这位大佬学习:http://t.csdn.cn/irwvx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。