Framework7无法正确加载页面

时间:2017-04-10 20:42:18

标签: javascript cordova html-framework-7

我有一个framework7应用程序:

var myApp = new Framework7();
var $$ = Dom7;
var mainView = myApp.addView('.view-main', {
    dynamicNavbar: true
});
myApp.onPageInit('index', function (page) {
    console.log('index page');
    mainView.router.loadPage('login.html');
}

它不会转换为login.html。

的index.html:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="lib/framework7/css/framework7.ios.min.css">
<link rel="stylesheet" href="lib/framework7/css/framework7.ios.colors.min.css">

<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/eventFeed.css">
<link rel="stylesheet" href="css/eventPage.css">
</head>
<body>
<!-- Status bar overlay for full screen mode (PhoneGap) -->
<div class="statusbar-overlay"></div>

<div class="panel-overlay"></div>
<div class="panel panel-left panel-reveal">
    <div class="list-block theme-gray">
        <div class="list-block-label" id="slideoutlist-name">User     Profile</div>
        <ul>
            <a href="EventFeed.html" class="item-link item-content close-panel">Feed</a>
        </ul>
        <ul>
            <a href="#" class="item-link item-content close-panel" id="logout">Logout</a>
        </ul>

    </div>
</div>
<div class="views">
<div class="view view-main">
    <div class="navbar" id="navbar">
        <div class="navbar-inner">
            <div class="right">

                <a href="#" class="link icon-only open-panel"><i class="icon icon-bars"></i></a>
            </div>
        </div>
    </div>

    <div class="pages navbar-through toolbar-through">
        <div data-page="index" class="page">
            <div class="page-content">
                <div class="content-block">
                    <p>INDEX PAGE</p>
                    <a href="EventFeed.html">Feed</a>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script type="text/javascript" src="lib/framework7/js/framework7.min.js">                    
</script>
<script type="text/javascript" src="lib/jquery/jquery.min.js"></script>
<script type="text/javascript" src="lib/facebook/all.js"></script>
<script type="text/javascript" src="js/my-app.js"></script>
</body>

</html>

登录是https://framework7.io/docs/login-screen.html上的标准登录。

它在大约一两天前工作,直到我合并分支机构。然后我又回到了这个分支,但它仍然无效。如果我执行mainView.router.loadPage(&#39; asdf.html&#39;)或任何其他页面,它可以工作,但它只适用于login.html。这是为什么?

2 个答案:

答案 0 :(得分:0)

根据您的路由设置方式,mainView.router.loadPage('login.html');使用的是Framework7 v1。您为登录页面链接的文档来自当前版本:v2。

首先使用:http://v1.framework7.io/docs/login-screen.html

答案 1 :(得分:-1)

任何这些都可以,(假设你的js代码正常工作):

return app.views.main.router.navigate('/home/', history = true);
return app.views.main.router.navigate('/about/', history = true);
return app.views.main.router.navigate('/', history = true);

导航方法的第一个参数(例如'/ home /或'/'或'/ about /')是route.js文件中的路径。