Giter Site home page Giter Site logo

Comments (1)

dequan1331 avatar dequan1331 commented on August 15, 2024

1.这个问题看现象是因为注入的JS回收之后有问题了,因为第一次注入之后,webview进行了回收,影响了你这里的JS。但是具体的问题需要debug看下第二次使用时,JS是否注入成功,是否是undefined以及不能显示正常内容的原因等等,这里需要针对具体的case进行解决。简单的做法就是每次在webview finishNavigation的时候,都注入一遍JS。 同时对于JS注入这里,可以创建一个自己的 WebView 继承自 HPKWebView。重写对应的initWithFrame方法。这样可以实现自定义的WKWebViewConfiguration逻辑,同时也不会影响框架内部的逻辑。同时在webview回收的对应protocol里,设置removeAllUserScripts。

  1. 这个问题基本业界的做法都是相同的,就是在支持复用的同时,为了解决首次的加载速度,预热一个。具体就是在app初始化的时候,先尝试取一个WebView,这个时候没有默认框架会创建一个,之后在回收掉进入回收池,就是先dequeueWebViewWithClass然后在enqueueWebView。这里要注意如果你需要设置UA等一些webview的特性,需要在这一步之前进行设置,防止这个webview带不上。

from hybridpagekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.