coming soon
+ + +diff --git a/component/async/index.html b/component/async/index.html index fc7a373c..ffebddb9 100644 --- a/component/async/index.html +++ b/component/async/index.html @@ -118,13 +118,13 @@
组件实
该文档描述了组件的 API,在 San 主模块上暴露的 API 请参考文档 主模块API。
解释
:
组件初始化数据。通常在组件反解的场景下使用。
+组件初始化数据。通常在组件反解的场景下使用。
类型
: Object
用法
:
1 | var MyComponent = san.defineComponent({}); |
解释
:
组件根元素。传入此参数意味着不使用组件的 template 作为视图模板,组件视图由 San 自动反解。详情可参考组件反解文档。
+组件根元素。传入此参数意味着不使用组件的 template 作为视图模板,组件视图由 San 自动反解。详情可参考组件反解文档。
类型
: HTMLElement
用法
:
1 | var MyComponent = san.defineComponent({}); |
更多说明请参考owner与parent文档。
+更多说明请参考owner与parent文档。
注意
:
指定 owner 后,不允许将组件 push 到 owner 的 children 中
用法
:
版本
:>= 3.7.0
类型
: string|Object
解释
:
通过 HTML 格式的一个标签,声明组件与 owner 之间的数据绑定和事件。指定 source 同时需要指定 owner。更详细的用法请参考 手动创建子组件 文档,更多声明格式细节请参考 模板 与 事件 文档。
+通过 HTML 格式的一个标签,声明组件与 owner 之间的数据绑定和事件。指定 source 同时需要指定 owner。更详细的用法请参考 手动创建子组件 文档,更多声明格式细节请参考 模板 与 事件 文档。
提醒
:
source 串的标签名称通常没什么用,除了以下情况:组件本身根节点为 template 时,以 source 的标签名称为准。
用法
:
1 | var MyComponent = san.defineComponent({ |
生命周期代表组件的生存过程,在每个过程到达时将触发钩子函数。具体请参考生命周期文档。
+生命周期代表组件的生存过程,在每个过程到达时将触发钩子函数。具体请参考生命周期文档。
解释
:
组件视图模板编译完成。组件上的 compiled 方法将会被调用。
解释
:
解释
:
当捕获一个来自子孙组件的抛出异常时被调用。此钩子会收到三个参数:错误对象、发生错误的组件实例以及一个包含异常来源信息的字符串。此钩子捕获异常以后,不会再继续向父节点传递。
解释
:
组件的视图模板。详细描述请参考视图模板文档。
+组件的视图模板。详细描述请参考视图模板文档。
类型
: string
用法
:
1 | san.defineComponent({ |
解释
:
声明组件视图模板中可以使用哪些过滤器。详细描述请参考过滤器文档。
+声明组件视图模板中可以使用哪些过滤器。详细描述请参考过滤器文档。
类型
: Object
用法
:
1 | san.defineComponent({ |
解释
:
声明组件中可以使用哪些类型的子组件。详细描述请参考components文档。
+声明组件中可以使用哪些类型的子组件。详细描述请参考components文档。
类型
: Object
用法
:
1 | var AddForm = san.defineComponent({ |
解释
:
声明组件中的计算数据。详细描述请参考计算数据文档。
+声明组件中的计算数据。详细描述请参考计算数据文档。
类型
: Object
用法
:
1 | san.defineComponent({ |
解释
:
声明处理子组件派发消息的方法。详细描述请参考消息文档。
+声明处理子组件派发消息的方法。详细描述请参考消息文档。
类型
: Object
用法
:
1 | var Select = san.defineComponent({ |
解释
:
返回组件实例的初始数据。详细描述请参考初始数据文档。
+返回组件实例的初始数据。详细描述请参考初始数据文档。
类型
: function():Object
用法
:
1 | var MyApp = san.defineComponent({ |
1 | var MyComponent = san.defineComponent({ |
解释
:
属性透传功能是否生效。默认值为 true。当属性透传功能关闭时,id / class / style 的透传也将失效。
+版本
:>= 3.14.1
类型
: boolean
用法
:
1 | var MyComponent = san.defineComponent({ |
解释
:
组件根节点是否应用外部通过绑定传入的 id / class / style。默认为 true。
版本
:>= 3.7.5
描述
: on({string}eventName, {Function}eventListener)
解释
:
添加自定义事件监听器。 on 一般仅用在使用 JavaScript 动态创建的组件中,通过视图模板创建的子组件应通过 on- 的方式绑定监听。可参考动态子组件文档
+添加自定义事件监听器。 on 一般仅用在使用 JavaScript 动态创建的组件中,通过视图模板创建的子组件应通过 on- 的方式绑定监听。可参考动态子组件文档
描述
: un({string}eventName, {Function=}eventListener)
解释
:
移除事件监听器。 当 eventListener 参数为空时,移除所有 eventName 事件的监听器。
描述
: dispatch({string}name, {*}value)
解释
:
派发一个消息。消息将沿着组件树向上传递,直到遇到第一个处理该消息的组件。上层组件通过 messages 声明组件要处理的消息。消息主要用于组件与非 owner 的上层组件进行通信。可参考消息文档。
+派发一个消息。消息将沿着组件树向上传递,直到遇到第一个处理该消息的组件。上层组件通过 messages 声明组件要处理的消息。消息主要用于组件与非 owner 的上层组件进行通信。可参考消息文档。
用法
:
1 | var SelectItem = san.defineComponent({ |
描述
: watch({string}dataName, {function({*}value)}listener)
解释
:
监听组件的数据变化。通常我们使用绑定,在子组件数据变化时自动更新父组件的对应数据。 watch 一般仅用在使用 JavaScript 动态创建的组件中。可参考动态子组件文档
+监听组件的数据变化。通常我们使用绑定,在子组件数据变化时自动更新父组件的对应数据。 watch 一般仅用在使用 JavaScript 动态创建的组件中。可参考动态子组件文档
1 | san.defineComponent({ |
描述
: ref({string}name)
解释
:
获取定义了 s-ref 的子组件或 HTMLElement。详细请参考组件层级文档。
+获取定义了 s-ref 的子组件或 HTMLElement。详细请参考组件层级文档。
注意
:组件根元素即使定义了 s-ref,也无法通过 ref 方法获得。获取组件根元素请使用 this.el。
用法
:
1 | var AddForm = san.defineComponent({ |
描述
: {Array} slot({string=}name)
解释
:
获取组件插槽的节点信息。返回值是一个数组,数组中的项是节点对象。通常只有一项,当 slot 声明中应用了 if 或 for 时可能为 0 项或多项。节点对象包含 isScoped 、 isInserted 和 children。
-插槽详细用法请参考 slot 文档。
+插槽详细用法请参考 slot 文档。
注意
:不要对返回的 slot 对象进行任何修改。如果希望操作视图变更,请操作数据。
用法
:
1 | var Panel = san.defineComponent({ |
描述
: {Function} defineComponent({Object}propertiesAndMethods)
解释
:
方法 。定义组件的快捷方法。详细请参考 组件定义 文档。
+方法 。定义组件的快捷方法。详细请参考 组件定义 文档。
用法
:
1 | var MyApp = san.defineComponent({ |
版本
:>= 3.12.0
描述
: {Function} defineTemplateComponent({string|Object}templateOrOptions)
解释
:
方法 。定义模板组件。详细请参考 模版组件 文档。
+方法 。定义模板组件。详细请参考 模版组件 文档。
用法
:
1 | var PanelWithHeader = san.defineTemplateComponent( |
版本
:>= 3.7.0
描述
: {Object} createComponentLoader({Object|Function}options)
解释
:
方法 。创建组件 Loader,主要应用于子组件的后加载与异步渲染,详细请参考 异步组件 文档。 options 参数为 Object 类型时,支持如下成员:
+方法 。创建组件 Loader,主要应用于子组件的后加载与异步渲染,详细请参考 异步组件 文档。 options 参数为 Object 类型时,支持如下成员:
类型
: Function
解释
:
属性 。组件类,定义组件时可以从此继承。通常通过 san.defineComponent 定义组件,不使用此方法。详细请参考组件定义文档。
+属性 。组件类,定义组件时可以从此继承。通常通过 san.defineComponent 定义组件,不使用此方法。详细请参考组件定义文档。
用法
:
1 | import {Component} from 'san'; |
描述
: inherits({Function}SubClass, {Function}SuperClass)
解释
:
方法 。一个通用的实现继承的方法,定义组件时可以使用此方法从 san.Component 继承。通常在 ES5 下通过 san.defineComponent 定义组件,在 ESNext 下使用 extends 定义组件。
-绝大多数情况不推荐使用此方法。详细请参考组件定义文档。
+绝大多数情况不推荐使用此方法。详细请参考组件定义文档。
版本
:>= 3.1.0
描述
: {function(Object):string} compileToRenderer({Function}ComponentClass)
解释
:
tips
: Given the independence of components, San does not provide a way to register global filters. Defining the filters used by components must be in their own filters.
The position of a slot can be declared in the view template by slot, the content of which can be defined by the outer component. Refer to the slot document for more details.
+The position of a slot can be declared in the view template by slot, the content of which can be defined by the outer component. Refer to the slot document for more details.
1 | var Panel = san.defineComponent({ |
The proper
This document describes components API, the San module API
please refer to San API.
Explanation
:
Component initialization data. Usually used in the component reversion scenario.
+Component initialization data. Usually used in the component hydrate scenario.
Type
: Object
Usage
:
1 | var MyComponent = san.defineComponent({}); |
explanation
:
Component root element. Passing in this parameter means that the component’s template is not used as the view template, and the component view is automatically reversed by San. See here for more details.
+Component root element. Passing in this parameter means that the component’s template is not used as the view template, and the component view is automatically reversed by San. See here for more details.
type
: HTMLElement
code
:
1 | var MyComponent = san.defineComponent({}); |
1 | var MyComponent = san.defineComponent({ |
The life cycle represents the survival process of the component, and the hook function is triggered when each process arrives. See lifecycle for more details.
+The life cycle represents the survival process of the component, and the hook function is triggered when each process arrives. See lifecycle for more details.
explanation
:
The component view template is compiled. The compiled method on the component will be called.
explanation
:
explanation
:
Called when an error from any descendent component is captured. The hook receives three arguments: the error, the component instance that triggered the error, and a string containing information on where the error was captured. The hook will stop the error from propagating further.
explanation
:
The view template for the component. see component template for more details.
+The view template for the component. see component template for more details.
type
: string
usage
:
1 | san.defineComponent({ |
explanation
:
Declare which filters can be used in a component view template. see filter for more details.
+Declare which filters can be used in a component view template. see filter for more details.
type
: Object
usage
:
1 | san.defineComponent({ |
explanation
:
Declare which types of subcomponents can be used in a component. see components for more details.
+Declare which types of subcomponents can be used in a component. see components for more details.
type
: Object
usage
:
1 | var AddForm = san.defineComponent({ |
explanation
:
Declare the calculated data in the component. see computed data for more details.
+Declare the calculated data in the component. see computed data for more details.
type
: Object
usage
:
1 | san.defineComponent({ |
explanation
:
declare how to handle subcomponent dispatch messages. see message for more details.
+declare how to handle subcomponent dispatch messages. see message for more details.
type
: Object
usage
:
1 | var Select = san.defineComponent({ |
explanation
:
Return the initial data of the component instance. see init data for more details.
+Return the initial data of the component instance. see init data for more details.
type
: function():Object
usage
:
1 | var MyApp = san.defineComponent({ |
description
: on({string}eventName, {Function}eventListener)
explanation
:
Add a custom event listener. on is generally only used in components that are dynamically created using JavaScript. Subcomponents created through view template should be bound by on-. see dynamic child components for more details.
+Add a custom event listener. on is generally only used in components that are dynamically created using JavaScript. Subcomponents created through view template should be bound by on-. see dynamic child components for more details.
description
: un({string}eventName, {Function=}eventListener)
explanation
:
Remove event listener. Remote the listeners for all eventName events when the eventListener params is empty.
description
: dispatch({string}name, {*}value)
explanation
:
Dispatch a message. The message will be passed up in the component tree util it encounters the first component that processes the message. The upper component declares the message to be processed by the component via message. The message is mainly used for communication between components with none owner upper components. see message for more details.
+Dispatch a message. The message will be passed up in the component tree util it encounters the first component that processes the message. The upper component declares the message to be processed by the component via message. The message is mainly used for communication between components with none owner upper components. see message for more details.
usage
:
1 | var SelectItem = san.defineComponent({ |
description
: watch({string}dataName, {function({*}value)}listener)
explanation
:
Watch component’s data changes. Usually we use bindings to automatically update the corresponding data of the parent component when the child component data changes. watch is generally only used in components that are dynamically created using JavaScript. see dynamic child components for more details.
+Watch component’s data changes. Usually we use bindings to automatically update the corresponding data of the parent component when the child component data changes. watch is generally only used in components that are dynamically created using JavaScript. see dynamic child components for more details.
1 | san.defineComponent({ |
description
: ref({string}name)
explanation
:
Get the subcomponents that define s-ref. see component level for more details.
+Get the subcomponents that define s-ref. see component tree for more details.
usage
:
1 | var AddForm = san.defineComponent({ |
version
: >= 3.3.0
description
: {Array} slot({string=}name)
explanation
:
Get the node information of the component slot. The return value is an array, and the items in the array are node objects and usually only one. And there will be more that one node objects when if or for is applied in the slot declaration. The node objects include isScoped
, isInserted
, and children
property. see slot for more details.
Get the node information of the component slot. The return value is an array, and the items in the array are node objects and usually only one. And there will be more that one node objects when if or for is applied in the slot declaration. The node objects include isScoped
, isInserted
, and children
property. see slot for more details.
attention
: do not make any modifications to the returned slot object. If you want to manipulate the view changes, please manipulate the data.
usage
:
1 | var Panel = san.defineComponent({ |
Description
: defineComponent({Object}propertiesAndMethods)
Explanation
:
Method. A shortcut to define components. Refer to Component Definition for details.
+Method. A shortcut to define components. Refer to Component Definition for details.
Usage
:
1 | var MyApp = san.defineComponent({ |
Type
: Function
Explanation
:
Property. The component class, from which the newly defined components will inherit. For most cases the san.defineComponent method should be used instead. Refer to Component Definition for details.
+Property. The component class, from which the newly defined components will inherit. For most cases the san.defineComponent method should be used instead. Refer to Component Definition for details.
Usage
:
1 | import {Component} from 'san'; |
Description
: inherits({Function}SubClass, {Function}SuperClass)
Explanation
:
Method. An util method to implement inheritance, which is the case when defining components (inherit from san.Component). Usually, to define a component we use san.defineComponent in ES5 and extends in ESNext.
-It is not recommended to use .inherits()
in most cases. Refer to Component Definition for details.
It is not recommended to use .inherits()
in most cases. Refer to Component Definition for details.
Version
:>= 3.1.0
Description
: {function(Object):string} compileToRenderer({Function}ComponentClass)
Explanation
:
coming soon
+ + +Version
: >= 3.5.5
Explanation
:
Force update the view even if the data to be set is identical to the existing value. Available for .set()
method only.
Validation rules can be specified for component data. san will throw the corresponding error when validation fails. It’s rather useful in collaboration.
+Use DataTypes
to declare validation rules:
1 | import san, {DataTypes} from 'san'; |
DataTypes
provides a series of validators to ensure the data received is valid. In the above example, a DataTypes.string
validator is used so that san will throw an error when the value for name
is not a String
.
For performance considerations, dataTypes
only get evaluated in development
environment.
Please refer to this link to check out their availabilities in different san releases.
+Following is a demo for a variety of DataTypes
validators:
1 | import san, {DataTypes} from 'san'; |
Th