0
我有一個登錄系統,我需要在localstorage上登錄用戶,一旦用戶登錄,我想在他訪問登錄頁面時將他重定向到他自己的頁面。爲什麼我的房產不會反映鐵本地存儲價值?
我的模板:
<iron-localstorage name="user-storage" value="{{storedUser}}"></iron-localstorage>
我的目標:
static get properties() {
return {
storedUser: {
type: Object,
notify: true
},
...
}
}
我想這樣做:
redirect() {
console.log(this.storedUser);
if(this.storedUser) {
// Redirect user or admin to their own homescreen
if(this.storedUser.role == 'user')
this.set('route.path', '/homescreen-usuario');
else if(this.storedUser.role == 'admin')
this.set('route.path', '/homescreen-admin');
else
this.set('route.path', '/my-view404');
}
}
但第一行始終記錄 「不確定」。