我的-app.js中有这个:
var myApp = new Framework7({
closeByOutsideClick : true,
init: false
});
var $$ = Dom7;
// Add view
var mainView = myApp.addView('.view-main');
function avvia(info) {
$.ajax({
type: "POST",
contentType: "application/json",
//data: {info : info},
data : JSON.stringify(info),
timeout: 6000,
url: "http://localhost:8180/api/",
success: function(data){
urlRedirect = data.urlRedirect;
//window.location.href = urlRedirect;
mainView.router.loadPage(urlRedirect);
},
beforeSend: function() {
myApp.showPreloader('Loading...');
},
complete: function(data) {
myApp.hidePreloader();
},
error: function (xhr, status, error) {
// executed if something went wrong during call
myApp.alert(error, ' Error');
//if (xhr.status > 0) alert('got error: ' + status); // status 0 - when load is interrupted
}
});
}
myApp.init();
在ajax调用之后,我希望将页面重定向到一个新页面,如果成功的话,该页面将作为数据字段返回。我的问题是Framework7导航mainView.router.loadPage(urlRedirect)
不能工作,而标准window.location.href = urlRedirect;
工作正常。我该怎么解决呢?
发布于 2017-04-18 12:22:18
您的urlRedirect是仅返回Ajax页面所需的HTML,还是返回完整Framework7应用程序的html?我的意思是,如果您返回的不仅仅是Ajax页面的结构,路由器将不知道如何处理它,而且可能什么也不做。
如果您调用loadPage( url ),则url应该只包含以下内容:
<div class="page" data-page="about">
... About page content goes here
</div>
此外,导航条标记、页眉/页脚等,但没有其他。
https://stackoverflow.com/questions/43235980
复制相似问题