Framework7:登录重定向 [英] Framework7: Login redirect
本文介绍了Framework7:登录重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户访问login.html页面时,localStorage用于检查用户是否已登录。该页面应重定向到profile.html并显示notofication消息。
显示消息,但页面(login.html)是相同的..
When user visits login.html page, localStorage is used to check if a user is logged in. The page should redirect to profile.html and display notofication message. The message is displayed, but the page (login.html) is the same..
if( localStorage.user_login ) {
mainView.router.loadPage({url:'profile.html', ignoreCache:true, reload:true });
myApp.addNotification( {
message: 'Welcome '+ localStorage.user_username +'!'
} );
}
如果用户登录,如何重定向页面?
How can i make the page redirect if the user is logged in?
推荐答案
把它放在myApp framework7初始化之前。
put this before myApp framework7 initialization.
$$(document).on('pageInit', function (e) {
var page = e.detail.page;
if (page.name === 'index') {
try{
var storedData = window.localStorage['f7form-'+ 'idofyourloginform'];
if(storedData) {
//do your ajax login request here
// if successful do your login redirect
mainView.router.loadPage({url:'profile.html', ignoreCache:true, reload:true });
}
}
);
这篇关于Framework7:登录重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文