我目前正在做一个项目,我需要在 webview 中加载用户,同时我正在注入(inject)一个 javascript 代码来检查 token 是否过期。到这里一切正常,我从 webview 收到一条消息,我们需要刷新,但我不知道如何在运行时在 webview 中注入(inject) javascript。我目前正在使用这个模块:https://github.com/alinz/react-native-webview-bridge .
有没有办法让这个流程发挥作用?因此,如果用户正在使用该应用程序, token 将不会过期。
最佳答案
您不能只在页面正文中插入一个新的脚本元素吗?
也许类似于这个问题的答案:Adding <script> element to the DOM and have the javascript run?
关于javascript - React-Native:在运行时在 webview 中动态注入(inject) javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39580034/