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

你好,请问在什么时候调用? #3

Closed
vortesnail opened this issue Jun 3, 2020 · 3 comments
Closed

你好,请问在什么时候调用? #3

vortesnail opened this issue Jun 3, 2020 · 3 comments

Comments

@vortesnail
Copy link

你好作者,关于调用时机有以下几个简单问题想请教一下:
1、通过 script 引入 执行实例化,比如你项目中的 index.html 中写在了 body 的顶部,这样还未渲染完成就执行,数据不会有问题吗?(是否要在 window.onload 中执行实例化)
2、React 项目中如何使用才能得到页面的性能数据?也是写在 html 中吗?

希望得到作者的回答,这个问题很困扰~

@WarrenJones
Copy link
Owner

1.数据不会有问题,因为是在相应的生命周期才有回调的。
2.页面直接引用nemetric就可以了,也可用它测试longtask
nemetric.start('AppAfterPaint');
nemetric.endPaint('AppAfterPaint');

@vortesnail
Copy link
Author

@WarrenJones 那我在react项目中任意位置调用最终数据都一样的吗?

@WarrenJones
Copy link
Owner

@WarrenJones 那我在react项目中任意位置调用最终数据都一样的吗?

是的哈,你可以测试一下

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