尝试:
$(document).on( 'mobileinit' , function(){ // will fire as soon as jQM is loaded
var user = Kinvey.getActiveUser();
var promise = Kinvey.User.me({
success: function(response) {
$.mobile.changePage('#login', {transition: 'none'}); //should change page here
});
}
替代方案可能包括:
$('#home').on( 'pageinit' ,function(){ /*stuff*/ }); //will fire the first time #home is loaded
$('#home').on( 'pagebeforeshow' ,function(){ /*stuff*/ }); //will fire before home is shown (don't do this, it'll check every time)
如果您使用的是cordova并在配置中启用了启动页面,您可以尝试:
$(document).on( 'mobileinit' , function(){ // will fire as soon as jQM is loaded
var user = Kinvey.getActiveUser();
var promise = Kinvey.User.me({
success: function(response) {
$.mobile.changePage('#login', {transition: 'none'}); //should change page here
if (navigator.splashscreen /* || 1 */ ){ // so it doesn't crash when you're testing on your browser
navigator.splashscreen.hide();
}
}
});