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

请教一下,如果依赖运行时的参数的话有没有什么好的实现方式 #11

Open
li2go opened this issue Jan 14, 2020 · 1 comment

Comments

@li2go
Copy link

li2go commented Jan 14, 2020

目前装饰器的实现只能解决预定义的事件行为和参数的track。
track如果需要业务相关的参数的话,有没有优雅的方法。

另外的,通过data-track 和ref来绑定一些组件的统计,实在是太不优雅了哦,可以考虑使用hoc实现

@l-hammer
Copy link
Owner

l-hammer commented Jan 15, 2020

业务相关的参数可以尝试用context获取。

export default {
  22121(context) {
    trackAction("22121", { tamp: context.date });
  }
}

context其实是state 和 props的一个浅拷贝。

const context = { ...this.state, ...this.props };

目前仅在区域曝光埋点中用到了data-trackref,确实不够优雅。感谢建议,也欢迎PR哦。

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