如何确定我回到了 framework7 中的索引页面

How to determine that I'm back on index page in framework7

在我的 index.html 中,我有这个按钮,点击后会转到 about.html

<div class="col-50">
    <a href="about.html">
        <div class="button">About</div>
    </a>
</div>

并且在“关于”页面上,我想检测什么时候 back 按钮被点击并且我现在在我的 index.html 页面上。

这是我尝试过的方法:

第一次尝试:

myApp.onPageInit('index', function (page) {
    myApp.alert("test");
});

第二次尝试:

myApp.onPageInit('index', function (page) {
    myApp.alert("test");
}).trigger();

你试过了吗:

myApp.onPageBack("about", function() {
  myApp.alert("test");
});

不要忘记 about 页面中的 data-page="about" 属性。

  <div class="pages">
    <div class="page" data-page="about">
      <div class="page-content">
        ... page content goes here ...
      </div>
    </div>
  </div>