<lynx-view> Web
<lynx-view> is a container component that loads and displays Lynx templates. It can be used in web applications to render Lynx templates.
After completing the above integration, you can achieve more flexible interaction control through the APIs provided by Lynx for Web. Here is a detailed description of the core APIs:
lynx-view
Attributes
Properties
nativeModulesMap
Custom NativeModule where key is the module name and value is the module implementation (an ESM URL):
Example:
onNativeModulesCall
Entry point for handling NativeModules (JSB, etc.) related calls:
Example:
browserConfig
Set browserConfig allowing the systemInfo payload to be dynamically configured at the instance level.
Events
error
Error message notification:
Methods
updateData
updateGlobalProps
sendGlobalEvent
Width and Height
The internal layout of lynx-view will be forced out of the external layout flow
We will force all lynx-view elements to apply CSS Containment.
That is, by default, you need to set a width and height for lynx-view. The width and height can be allocated by flex-grow or specified as a percentage, but cannot be "stretched". Setting width and height is a strongly recommended practice and also a best practice for performance.
In some cases where you really need the width or height to be determined by the content of lynx-view, you can set height="auto" or width="auto" to enable the automatic width/height listener. In this case, the internal layout of lynx-view remains independent of the external layout flow.
FAQ
Runtime error: Uncaught SecurityError: Failed to construct 'Worker': Script at 'xxx' cannot be accessed from origin 'xxx'.
This is because Worker loading remote scripts needs to comply with the Same-Origin Policy, and the JS resources of the project are generally deployed on CDN, causing cross-origin issues.
This can be solved by introducing remote-web-worker:
Performance Optimization
We provide an RSBuild plugin for performance optimization. You can introduce this plugin in your web project.
Compatibility
LCD tables only load in the browser
Migrating from older versions
If you are upgrading to @lynx-js/web-core@0.20.0, notice that there are significant breaking changes due to an architectural upgrade.
Changes to initialization
You no longer need to import CSS manually, nor do you need @lynx-js/web-elements. The initialization is simplified:
Changes to API
The following <lynx-view> properties are removed and no longer supported:
thread-strategycustomTemplateLoaderoverrideLynxTagToHTMLTagMapinject-head-links