Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page 的 on 事件,增加拦截器功能。 #51

Closed
shenqihui opened this issue Feb 24, 2017 · 1 comment · May be fixed by jasonwongX/wepy#5
Closed

page 的 on 事件,增加拦截器功能。 #51

shenqihui opened this issue Feb 24, 2017 · 1 comment · May be fixed by jasonwongX/wepy#5

Comments

@shenqihui
Copy link
Contributor

使用场景:

1、 用户分享页面出去,触发 onShareAppMessage ,api 规定是返回一个 Object ,所以可以在 wepy.page 的 onShareAppMessage 执行返回之后,对 Object 进行二次设置,在进行返回。
貌似这个不适合 promise 。官方 demo 上不支持。

2、其他用户点击,触发动作 onload ,这时候 options 先经过拦截器进行拦截,设置 options ,用设置之后的 options 进行 wepy.page 的 onload 事件的回调,此时可加 promise 。

简单实用场景如上。

希望能开发这个功能。

@Gcaufy
Copy link
Collaborator

Gcaufy commented Mar 13, 2017

这个功能可以有更简单的实现。

定义基类:

exports myPage extends wepy.page {
    onLoad () {
        doSomething()
    }
}

页面继承基类。

exports index extends myPage {
    onLoad () {
        super.onLoad();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants