我遵循后面使用php的vue登录教程。
我想用假json来检查电子邮件和用户名是否与假json相同。
因为我不知道什么原因不起作用。 我进入控制台
http://localhost:9050/users 404 (Not Found)
脚本
import VueResource from 'vue-resource'
const AuthPlugin = {
setToken(token) {
localStorage.setItem('authToken', token);
}
}
const users = {
email: 'example@example.com',
password: 'example1234'
}
export default {
name: 'login',
data() {
return {
user: {
email: '',
password: ''
}
}
},
methods: {
login() {
this.$http.get("http://localhost:9050/users", this.user)
.then((response) => {
this.AuthPlugin.setToken(response.body.token);
console.log('token', token)
this.$router.push('/home');
})
}
}
}
HTML
<form novalidate>
<h3>Log in</h3>
<div>
<input type="email" id="email" placeholder="E-mail" required minlength="6" maxlength="100" v-model="user.email">
</div>
<div>
<input type="password" id="password" placeholder="Password" required minlength="6" maxlength="20" v-model="user.password">
<p class="caps-lock-alert" style="display:none;"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Caps lock is on <i class="fa fa-exclamation-triangle" aria-hidden="true"></i></p>
</div>
</form>