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

opts.onEnter 回调函数的参数顺序问题 #91

Closed
codering opened this issue Sep 18, 2015 · 1 comment
Closed

opts.onEnter 回调函数的参数顺序问题 #91

codering opened this issue Sep 18, 2015 · 1 comment

Comments

@codering
Copy link

文档是这样说的:

{Function} opts.onEnter 进入状态触发,可以返回false,或任意不为true的错误信息或一个promise对象,用法跟视图的$onEnter一致
{Function} onEnter.params 视图所属的state的参数
{Function} onEnter.resolve $onEnter return false的时候,进入同步等待,直到手动调用resolve
{Function} onEnter.reject 数据加载失败,调用

使用时,

onEnter: function(rs ,rj){
        console.log(arguments)
        setTimeout(function(){
                 rs(true)
         },300)
         return false
 }

遇到的问题是:
当路由上有参数时, arguments[0]为参数对象;
当没有参数时,arguments[0]为resolve函数;

假如我的onEnter是一个公用的,我就不得不判断一下当前的arguments,因为它可能会变!

建议:将onEnter的路由参数放到 resolve, reject函数的后面,因为这两个是必须的。

@gogoyqj
Copy link
Contributor

gogoyqj commented Sep 22, 2015

这个是为了兼容之前的参数设计

@codering codering closed this as completed Oct 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants