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