Closed stupidchou closed 1 year ago
When I inject js in iOS, there will be some errors, how should I inject custom js?
You should load up JS using traditional means, such as a <script>
tag.
Alternatively, you can use the standard Function constructor, which will create a function with the scope of the global object, but this isn't the recommended approach due to similar issues (although less severe) to the standard eval function. MDN writes about the bad practices behind both eval
and the Function
constructor.
If you're authoring a Cordova plugin, then refer to the iOS plugin documentation. It contains examples of how to do cross communication between the native and javascript environments. Generally speaking, the application should respond to data with an appropriate, predefined function instead relying on the eval
solution, which will likely introduce a security risk into your app.
Bug Report
When I inject js in iOS, there will be some errors, how should I inject custom js?
Problem
When I inject js in iOS, there will be some errors, how should I inject custom js?
What is expected to happen?
When I inject js in iOS, there will be some errors, how should I inject custom js?
What does actually happen?
When I inject js in iOS, there will be some errors, how should I inject custom js?
Information
When I inject js in iOS, there will be some errors, how should I inject custom js?
Command or Code
When I inject js in iOS, there will be some errors, how should I inject custom js?
Environment, Platform, Device
When I inject js in iOS, there will be some errors, how should I inject custom js?
Version information
Checklist