我做水疗中心,所以我决定发送请求以下载用户。
如果用户是(即已授权的)用户,则应该从component-page registration / authorization
到main
页面进行重定向。
created() {
axios.post(
'/get-user'
)
.then(response => {
let user = null;
if (response.data.user) user = response.data.user;
this.$store.commit('auth', user);
let $this = this;
setTimeout(function() {
let routeName = $this.$router.history.current.name;
if ($this.$store.state.user && (routeName == 'auth' || routeName == 'register')) //$this.$store.commit('deniedAcces');
$this.$router.push({name: 'main'});
$this.$store.commit('preloaderHide');
}, 1200);
})
.catch(function (error) {
console.log(error);
});
},
该代码有效,但是如果将其从main
页转到授权页,则会显示错误
node_modules\bootstrap-vue\es\components\form-input\form-input.js строка 123
实际上,即使您已经登录并单击从标题到主页的转换,也会发生错误。
https://gitlab.com/Kir1/laraspa.git
commit 2
app.js:6042 Uncaught TypeError: Cannot set property 'value' of undefined
at VueComponent.setValue (app.js:6042)
at VueComponent.onInput (app.js:6051)
at invoker (app.js:28784)
at HTMLInputElement.fn._withTask.fn._withTask (app.js:28569)
setValue @ app.js:6042
onInput @ app.js:6051
invoker @ app.js:28784
fn._withTask.fn._withTask @ app.js:28569