Ale.js

Component Foundation

Preface

In the introductory chapter, you’ve learned some basic definitions and functions for rendering components. These foundations will not appear in this chapter. If you have not already learned some of the content, please visit the Introduction page.

Start

On the introduction page, we have some knowledge of the template property:

In fact, the template property also supports receiving a function, but the specific template needs to be returned using return:

Then we need to render this component:

So, what are the benefits of setting the template property to a function? In fact, it can automatically bind a property called data.

For example, we define a value named name in the data attribute and then render it:
[Before version 1.0.0, the actual use of this refers to this.data, and the 1.0.0 version replaces this with the ale component object after rendering](if you don’t know this sentence is What do you mean, please leave it alone)

Data

You can also dynamically set data when the component is rendered. Among them, the attribute with the same name will be reassigned:

Of course, the same component can also be rendered multiple times:

Local component

If you don’t add a name when defining a component, the Ale() function will return you a Ale local component build object:

You can render this component using the render function of Ale local component generation object:

Found some errors? Edit on Github!