vue.js - Eventsource problems with webpack and vuejs -
i'm making own blog using express , vuejs. in login.vue, found websites redirected localhost:8080/?#/login after pushed 'submit button' in chrome. (it works perfect in firefox) had log in 'twice' in order sign in.
after post 'request', following errors occur before (response) => { ... }
eventsource failed loading : "localhost:8080/__webpack_hmr" xhr failed loading: post "localhost:8080/login" navigated localhost:8080/?
but funny thing after redirected /?#/login, worked successful. want know why errors occured. guess might webpack error don't know how fix it.
<template> <div id="app"> <div class="alert alert-primary" role="alert" v-if="showalert"> <h4 class="alert-heading">{{alertstatus ? "success":"warning"}}</h4> <p>{{alertmsg}}</p> </div> <div v-if="!islogged"> <form> <ul class="nav nav-pills justify-content-center"> <li class="nav-item"> <a class="nav-link" v-bind:class="{ active: logmode }" v-on:click="changemode">sign in</a> </li> <li class="nav-item"> <a class="nav-link" v-bind:class="{ active: regmode }" v-on:click="changemode">sign up</a> </li> </ul> <div class="form-group" key="email"> <input type="email" class="form-control" id="email" v-model="email" aria-describedby="emailhelp" placeholder="enter email"> <small id="emailhelp" class="form-text text-muted">we'll never share email else.</small> </div> <div class="form-group" v-if="regmode" key="email2"> <input type="email" class="form-control" id="emailconfirm" v-model="emailconfirm" placeholder="enter email again"> </div> <div class="form-group" v-if="regmode" key="nick"> <input type="text" class="form-control" id="nickname" v-model="nick" placeholder="enter nickname"> </div> <div class="form-group" key="password"> <input type="password" class="form-control" id="password" v-model="password" placeholder="password"> </div> <div class="form-check" key="check"> <label class="form-check-label"> <input type="checkbox" class="form-check-input"> check me out </label> </div> <button v-on:click="submit" class="btn btn-primary">{{ismode}}</button> </form> </div> <div v-else> <span> signed in. </span> </div> </div> </template> <script> export default { name: 'login', computed: { logmode: function () { if (this.ismode === 'login') return true else return false }, regmode: function () { if (this.ismode === 'register') return true else return false } }, methods: { changemode: function () { if (this.ismode === 'login') this.ismode = 'register' else if (this.ismode === 'register') this.ismode = 'login' }, submit: function () { console.log('submit on') if (this.ismode === 'register') { this.$http.post('/register', { email: this.email, nick: this.nick, password: this.password }) .then((response) => { console.log('get response!') }) .catch(function (error) { console.log(error) }) } else { if (this.email) { console.log('email exist') this.$http.post('/login', { email: this.email, password: this.password }) .then((response) => { console.log('hello response!', response.data) var token = response.data.token if (token) { console.log('param test: ', this.email, response.data.nick, token) this.islogged = true this.token = token } }) .catch(function (error) { console.log(error) }) } } } }, data () { return { email: '', emailconfirm: '', nick: '', password: '', showalert: false, alertmsg: '', alertstatus: false, islogged: false, ismode: 'login', token: '' } } } </script> <style> #login{ margin: 50px; } .nav{ width: 320px; padding: 10px; } .inputs-move { transition: 1s; } .inputs-item { display: inline-block; } .inputs-enter-active, .inputs-leave-active { transition: 1s; } .inputs-enter, .inputs-leave-to { opacity: 0; transform: translatey(-30px); } </style>
Comments
Post a Comment