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');
}
}
但第一行始终记录 “不确定”。