📜  EmberJS-组件

📅  最后修改于: 2020-10-25 11:02:02             🧑  作者: Mango


Ember.js组件使用W3C Web组件规范,并提供真正的封装UI小部件。它包含三个主要规范,即模板影子DOM自定义元素。该组件在数据模板名称中声明,该名称具有路径名而不是纯字符串,并且以“ components /”为前缀。

下表列出了动作的动作事件-

S.No. Action Events & Description
1 Defining a Component

You can easily define a component in Ember.js and each component must have a dash in their name.

2 Component Lifecycle

Component lifecycle uses some of the methods in order to execute the code at specific times in a component’s life.

3 Passing Properties to a Component

The component doesn’t access the property directly in the template scope. Therefore, just declare the property at the time of component deceleration.

4 Wrapping Content in a Component

You can wrap the content in a component by using the templates.

5 Customizing a Component’s Element

You can customize the component’s element such as attributes, class names by using a subclass of Ember.Component in the JavaScript.

6 Using Block Params

The passed properties in a component can give back the result in a block expression.

7 Handling Events

The user events such as double-click, hovering, key press etc can be handled by event handlers. To do this, apply the event name as a method on the component.

8 Triggering Changes with Actions

Components can trigger the changes and communicate with events by using the actions.