dequan1331 / HybridPageKit

A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App.
MIT License
1.22k stars 184 forks source link

如何注入js #23

Closed wangweihu closed 5 years ago

dequan1331 commented 5 years ago

整体上来说,对于 WKWebView 系统提供了 addUserScript 这样的函数来让开发者在合适的时间注入 JS。当然也可以在任何时间执行 JS 函数来进行注入。 如果使用HybridPageKit提供的可复用的WebView,建议在重写componentViewWillLeavePool函数中注入JS,同时在componentViewWillEnterPool中remove。 如果是自定义的WebView,简单的在初始化的时候调用系统函数注入即可。