Skip to content

waihaolaoxu/JsFramework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

JS类库模版

Page

Page() 函数用来注册一个页面。接受一个 object 参数,其指定页面的初始数据、生命周期函数、事件处理函数等。

属性 类型 描述
onLoad Function 生命周期函数--监听页面加载
onReady Function 生命周期函数--监听页面初次渲染完成
onReachBottom Function 页面上拉触底事件的处理函数
onResize Function 页面相关事件处理函数--监听窗口变化
其他 Any 开发者可以添加任意的函数或数据到 object 参数中,在页面的函数中用 this 可以访问
示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <button onclick="page.test('行间调用')"></button>
</body>
</html>

var page = Page({
        onLoad: function () {
            this.test('触发onLoad');
        },
        onReady:function(){
            alert('触发onReady')
        },
        onReachBottom: function () {
            alert('到底了')
        },
        onResize:function(){
            alert('窗口变化了!')
        },
        test: function (p) {
            alert(p)
        }
    })

Releases

No releases published

Packages

No packages published