BelinChung/HiApp

如何实现pageInit

immime opened this issue · 2 comments

你好,感谢你的贡献!
我想要基于该项目结构,自己加入Swiper Slider,Framework7官网介绍说需要在pageInit回调中初始化。请问每个data-page属性对应的页面如何实现pageInit?

Initialize Swiper with JavaScript
(http://framework7.io/docs/swiper.html#swiper-slider-html-layout)

Note that Swiper container should be in DOM on a moment of initialization. So if you use slider not on home page, you need to initialize it within pageInit event

如果是已经基于该项目的结构,以contacts功能页面为例,可以看到有如下代码:

require('./contacts.less');

var appFunc = require('../utils/appFunc'),
    service = require('./service'),
    template = require('./contacts.tpl.html');

var contacts = {
    init: function(){
        contacts.bindEvents();
    },
    ...
};

module.exports = contacts;

上面代码的init就是会在pageInit的事件中会被调用。你的Swiper Slider的构造动作可以在这个地方写。

OK, 我已经实现了,谢谢!