__SetAttribute

Introduction

Sets an attribute for a specific Element node.

Syntax

__SetAttribute(element: Element, key: string, value: any) : void;

Parameters

KeyDescription
elementAny Element object.
keyA string representing the attribute key to be set.
valueAny value representing the attribute value to be set.

Return Value

No return value.

Example

The frontend framework can generate render instructions as follows.

<view src="xxx" />
// main-thread.js
let element = __CreateElement('view', 0, {});
__SetAttribute(element, 'src', 'xx');
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.