本文介绍了Vue+Flask实现简单的登录验证跳转,分享给大家,具体如下:
文件位置:
login.html
<Meta charset="UTF-8">
Login
<script type="text/javascript" src="../static/vue.js">
<script type="text/javascript" src="../static/axios.js">
<div id="login">
<script type="text/javascript">
var login = new Vue({
el: '#login',data:{
username: '',password: ''
},methods: {
login: function () {
axios.post('http://127.0.0.1:5000/login',{
username: this.username,password: this.password
}).then(function (response) {
console.log(response.status)
// 其实是应该走后台路由
if(parseInt(response.status) === 200){
window.location.href = 'index'
}
}).catch(function (error) {
console.log(error.response)
})
}
}
})