Lynx

loadTemplate

Using LynxLoadMeta to render LynxView, it is the main entrance for the client to load Lynx templates.

Syntax

Android

public void loadTemplate(@NonNull LynxLoadMeta meta);

Parameters

  • meta: Lynx template loads metadata, and developers use this data structure to specify optional data loaded by the template.

iOS

- (void)loadTemplate:(nonnull LynxLoadMeta *)meta;

Parameters

  • meta: Lynx template loads metadata, and developers use this data structure to specify optional data loaded by the template.

Harmony

LynxView has the following members:

  • url: String : Template file path.
  • buffer: ArrayBuffer: The binary file data of the template.
  • templateBundle: TemplateBundle: TemplateBundle object parsed in advance by the template's binary file data.
  • metaData: MetaData: Initial data specified by the client during the first screen loading process.
  • loadOption: LynxLoadOption: Additional configuration information when loading templates.
@Entry
@Component
struct Index {
  private url: string = 'playground/main.lynx.bundle';
  private buffer: ArrayBuffer = getTemplateBuffer();
  private metaData = new MetaData(
    new TemplateData('{"text":"TD"}'),
    new TemplateData({ "theme": "Light" }));

  build() {
    Column() {
      LynxView({
        url: this.url,
        buffer: this.buffer,
        metadata: this.metaData,
      }).width('100%').height('100%');
    }
    .size({ width: '100%', height: '100%' })
  }
}

Web

const lynxView = document.createElement('lynx-view');
lynxView.url = 'path/to/your/template.bundle';

Desktop (C++)

void LoadTemplate(std::shared_ptr<lynx::pub::LynxLoadMeta> load_meta);

Parameters

  • load_meta: The load metadata used to provide the template URL, binary data, template bundle, initial data, and global props.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.