问题描述
我正在尝试使用framework7,但无法触发页面初始化事件.我使用的代码非常简单,我非常仔细地遵循了文档.无论我做什么,它都不会触发(什么都没有记录到控制台,也没有错误).
I am trying to use framework7 and cannot get the page init event to fire. The code I am using is very simple, and I have followed the documentation very carefully. No matter what I do, it never fires (nothing is logged to the console, and no errors).
我创建了一个在此显示问题的笔.
我也用回调myApp.onPageInit
尝试了它.娜达.
I also tried it with the callback myApp.onPageInit
. Nada.
非常感谢任何帮助.
JS代码
var myApp = new Framework7({});
var $ = Dom7;
var mainView = myApp.addView('.view-main', {
dynamicNavbar: true
});
$(document).on('page:init', function (e) {
alert("processing page init");
});
HTML
<div class="views">
<div class="view view-main navbar-through toolbar-through">
<div class="navbar">
<div class="navbar-inner">
<div class="center">Framework7</div>
</div>
</div>
<div class="toolbar">
<div class="toolbar-inner">
<a href="#" class="link">Left</a>
<a href="#" class="link">Right</a>
</div>
</div>
<div class="pages">
<div class="page" data-page="home">
<div class="page-content">
<div class="content-block">
<p>Hi there!</p>
</div>
</div>
</div>
</div>
</div>
</div>
推荐答案
可以通过手动初始化应用(有时,在第一个加载的文件中包含内容时不会触发事件)
It may be solved by init app manually (sometimes event is not fired when content is in the first file loaded)
或者尝试触发您的主页回调(链接的第三点)
Or try to trigger your home page callback (third point of link)
这篇关于framework7页面初始化事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!