未验证 提交 56c16dc4 编写于 作者: O openharmony_ci 提交者: Gitee

!12039 翻译完成 9968/9857

Merge pull request !12039 from ester.zhou/C1-1201
# button
# button
> **NOTE**
>
> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
The **\<button>** component includes capsule, circle, text, arc, and download buttons.
## Child Components
Not supported
## Attributes
In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported.
## Attributes
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type | Default Value | Mandatory | Description |
| ---------------------- | ------- | ----- | ---- | ---------------------------------------- |
| type | string | - | No | Button type. The value cannot be dynamically updated. If this attribute is not set, a capsule-like button is displayed. Unlike the capsule button, the capsule-like button allows its corners to be configured using **border-radius**. Available button types are as follows:<br>- **capsule**: capsule button with fillets, background color, and text.<br>- **circle**: circle button that can accommodate icons.<br>- **text**: text button, which displays only text.<br>- **arc**: arc button. This value is applicable to wearables only.<br>- **download**: download button, with an extra download progress bar.|
| value | string | - | No | Text value of the button. |
| icon | string | - | No | Path of the button icon. The supported icon formats are JPG, PNG, and SVG. |
| placement<sup>5+</sup> | string | end | No | Position of the button icon in text. This attribute is valid only when **type** is not set. Available values are as follows:<br>- **start**: The button icon is at the beginning of the text.<br>- **end**: The button icon is at the end of the text.<br>- **top**: The button icon is at the top of the text.<br>- **bottom**: The button icon is at the bottom of the text.|
| waiting | boolean | false | No | Waiting status. When this attribute is set to **true**, a loading animation is displayed on the left of the text. This attribute does not work for download buttons.|
| Name | Type | Default Value | Mandatory | Description |
| ----------- | ------- | ------------- | --------- | ------------------------------------------------------------ |
| type | string | - | No | Dynamic modification is not supported. If this attribute is not set, capsule-like buttons are displayed. Different from the capsule button, the four rounded corners of a capsule-like button can be configured using **border-radius**. Available button types are as follows:<br>- **capsule**: a capsule button with fillets, background color, and text <br>- **circle**: a circle button which can be used to place icons <br>- **text**: a text button which displays the text only**arc**: an arc button. This value is applicable to wearables only.<br>- **download**: a download button. The download progress bar is added. |
| value | string | - | No | Text value of the button. |
| icon | string | - | No | Path of the button icon. The supported icon formats are JPG, PNG, and SVG. |
| placement5+ | string | end | No | Position of the button icon in text. This attribute is valid only when **type** is not set. Available values are as follows: <br>- **start**: The button icon is at the beginning of the text.<br>- **end**: The button icon is at the end of the text.<br>- **top**: The button icon is at the top of the text.<br>- **bottom**: The button icon is at the bottom of the text. |
| waiting | boolean | false | No | Waiting status. When **waiting** is set to **true**, the waiting transition is displayed on the left of the text. This attribute is unavailable for download buttons and wearables. |
## Styles
### When the Button Type Is Not **arc**
In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported.
### When the Button Type Is Not arc
In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported.
| Name | Type | Default Value | Mandatory | Triggered when |
| ----------- | ---------------- | ------------- | --------- | ------------------------------------------------------------ |
| text-color | \<color> | #ff007dff | No | Text color of the button. |
| font-size | \<length> | 16px | No | Font size of the button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.NOTE:If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart. |
| font-style | string | normal | No | Font style of the button. |
| font-weight | number \| string | normal | No | Font weight of the button. For details, see **font-weight** of the [text](../arkui-js/js-components-basic-text.md#section5775351116) component. |
| font-family | \<string> | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the font specified by [Custom Font Styles](../arkui-js/js-components-common-customizing-font.md) is used for the text. |
| icon-width | \<length> | - | No | Width of the internal icon of a circle button. The entire circle button is filled by default.NOTE:This style must be set when the icon uses the SVG image. |
| icon-height | \<length> | - | No | Height of the internal icon of a circle button. The entire circle button is filled by default.NOTE:This style must be set when the icon uses the SVG image. |
| radius | \<length> | - | No | Button radius. For a circle button, this style takes precedence over **width** and **height** in the common styles. |
> ![img]../public_sys-resources/icon-note.gif) **NOTE:**
>
> - For capsule buttons, border-related styles are not supported.
> - For circle buttons, text-related styles are not supported.
> - For text buttons, the text size is automatically adaptive, and **radius**, **width**, and **height** cannot be set. The **background-color** style is not supported when the background is completely transparent.
| Name | Type | Default Value | Mandatory | Description |
| ----------- | -------------------------- | --------------- | ---- | ---------------------------------------- |
| text-color | &lt;color&gt; | \#007dff | No | Text color of the button. |
| font-size | &lt;length&gt; | 16px | No | Font size of the button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings.<br>If the **config-changes** tag of **fontSize** is configured for abilities in the **config.json** file, the setting takes effect without application restart.|
| font-style | string | normal | No | Font style of the button. |
| font-weight | number \| string | normal | No | Font weight of the button. For details, see **font-weight** of the [**\<text>** component](../arkui-js/js-components-basic-text.md#styles).|
| font-family | &lt;string&gt; | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](../arkui-js/js-components-common-customizing-font.md) is used for the text. |
| icon-width | &lt;length&gt; | - | No | Width of the internal icon of a circle button. The entire circle button is filled by default.<br>This style must be set when the icon uses the SVG image.|
| icon-height | &lt;length&gt; | - | No | Height of the internal icon of a circle button. The entire circle button is filled by default.<br>This style must be set when the icon uses the SVG image.|
| radius | &lt;length&gt; | - | No | Corner radius of the button. For a circle button, this style takes precedence over **width** and **height** in the universal styles.|
### When the Button Type Is **arc**
In addition to the **background-color**, **opacity**, **display**, **visibility**, **position**, **[left|top****|right|bottom** styles in [Universal Styles](js-components-common-styles.md), the following styles are supported.
### When the Button Type Is arc
In addition to the **background-color**, **opacity**, **display**, **visibility**, **position**, and **[left|top|right|bottom]** styles in [Universal Styles](../arkui-js/js-components-common-styles.md), the following styles are supported.
| Name | Type | Default Value | Mandatory | Description |
| ----------- | -------------------------- | ---------- | ---- | ---------------------------------------- |
| text-color | &lt;color&gt; | \#de0000 | No | Text color of the arc button. |
| font-size | &lt;length&gt; | 37.5px | No | Font size of the arc button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings. |
| font-style | string | normal | No | Font style of the arc button. |
| font-weight | number \| string | normal | No | Font weight of the arc button. For details, see **font-weight** of the [**\<text>** component](../arkui-js/js-components-basic-text.md#styles).|
| font-family | &lt;string&gt; | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the specified [custom font](../arkui-js/js-components-common-customizing-font.md) is used for the text. |
| Name | Type | Default Value | Mandatory | Triggered when |
| ----------- | ---------------- | ------------- | --------- | ------------------------------------------------------------ |
| text-color | \<color> | #de0000 | No | Text color of the arc button. |
| font-size | \<length> | 37.5px | No | Font size of the arc button. |
| allow-scale | boolean | true | No | Whether the font size changes with the system's font size settings. |
| font-style | string | normal | No | Font style of the arc button. |
| font-weight | number \| string | normal | No | Font weight of the arc button. For details, see [font-weight](js-components-basic-text.md) of the **text** component. |
| font-family | \<string> | sans-serif | No | Font family, in which fonts are separated by commas (,). Each font is set using a font name or font family name. The first font in the family or the font specified by [Custom Font Styles](js-components-common-customizing-font.md) is used for the text. |
## Events
Events in [Universal Events](js-components-common-events.md) are supported.
The [universal events](../arkui-js/js-components-common-events.md) are supported.
## Methods
Methods in [Universal Methods](js-components-common-methods.md) are supported.
The [universal methods](../arkui-js/js-components-common-methods.md) are supported.
When the button type is **download**, the following methods are supported.
| Name | Parameter | Triggered when |
| ----------- | -------------------- | ------------------------------------------------------------ |
| setProgress | { progress:percent } | Progress bar of the download button. The value ranges from 0 to 100. The progress bar is displayed if the value is greater than 0. If the value is greater than or equal to 100, the progress bar is not displayed.NOTE:The text displayed on the progress bar is changed based on the value. |
| Name | Parameters | Description |
| ----------- | ------------------------------ | ---------------------------------------- |
| setProgress | { progress:percent } | Progress bar of the download button. The value ranges from 0 to 100. The progress bar is displayed if the value is greater than 0. If the value is greater than or equal to 100, the progress bar is not displayed.<br>The text displayed on the progress bar is subject to the **value** settings.|
## Example
```
```html
<!-- xxx.hml -->
<div class="div-button">
<button class="first" type="capsule" value="Capsule button"></button>
......@@ -89,6 +86,9 @@ When the button type is **download**, the following methods are supported.
onclick="progress">{{downloadText}}</button>
<button class="last" type="capsule" waiting="true">Loading</button>
</div>
```
```css
/* xxx.css */
.div-button {
flex-direction: column;
......@@ -129,7 +129,10 @@ When the button type is **download**, the following methods are supported.
text-color: white;
background-color: #007dff;
}
// xxx.js
```
```js
// xxx.js
export default {
data: {
count: 5,
......@@ -146,4 +149,4 @@ export default {
}
```
![img](figures/1.png)
\ No newline at end of file
![1](figures/1.png)
# list-item-group
**\<list-item-group>** is a child component of **<[list](js-components-container-list.md)>** and is used to group items in a list. By default, the width of **\<list-item-group>** is equal to that of **\<list>**.
> **NOTE**
>
> This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
**\<list-item-group>** is a child component of **[\<list>](../arkui-js/js-components-container-list.md)** and is used to group items in a list. By default, the width of **\<list-item-group>** is equal to that of **\<list>**.
- To use this component, you must set the **columns** attribute of the parent component **\<list>** to **1**. Otherwise, **\<list-item-group>** is not displayed.
- You can customize the width of each **\<list-item-group>**. However, if you retain the default value **stretch** of **align-items** for the parent component **\<list>**, the width of **\<list-item-group>** is equal to that of **\<list>**. You can set **align-items** to other values rather than **stretch** to make the customized **\<list-item-group>** width take effect.
- To use this component, you must set the **columns** attribute of the parent component **\<list>** to **1**. Otherwise, this component is not displayed.
- You can customize the width of each **\<list-item-group>**. However, if you retain the default value **stretch** of **align-items** for the parent component **\<list>**, the width of **\<list-item-group>** is equal to that of **\<list>**. To make the customized **\<list-item-group>** width take effect, set **align-items** to other values rather than **stretch**.
## Required Permissions
None
## Child Components
Only **<[list-item](js-components-container-list-item.md)>** are supported.
## Child Components
## Attributes
Only the **[\<list-item>](../arkui-js/js-components-container-list-item.md)** component is supported.
In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported.
## Attributes
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type | Default Value | Mandatory | Description |
| ---- | ------ | ------------- | --------- | ------------------------------------------------------------ |
| type | string | default | No | Type of the list-item-group. A list supports multiple list-item-group types. The same type of list-item-groups should have the same view layout after being rendered. When the type is fixed, replace the **if** attribute with the **show** attribute to ensure that the view layout remains unchanged. |
| Name | Type | Default Value | Mandatory | Description |
| ---- | ------ | ------- | ---- | ---------------------------------------- |
| type | string | default | No | Type of the list item group. A list supports multiple list item group types. The same type of list item groups must have the same view layout after being rendered. If the type is fixed, replace the **if** attribute with the **show** attribute to ensure that the view layout remains unchanged.|
> ![img](https://gitee.com/openharmony/docs/raw/OpenHarmony-3.1-Release/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:**
> **NOTE**
>
> **id** in the common attributes is used to identify a group. The input parameters of related functions and event information in the list also use **id** to uniquely identify a group.
> **id** in the universal attributes is used to identify a group. The input parameters of related functions and event information in the list also use **id** to uniquely identify a group.
## Styles
In addition to the styles in [Universal Styles](js-components-common-styles.md), the following styles are supported.
## Styles
In addition to the [universal styles](../arkui-js/js-components-common-styles.md), the following styles are supported.
| Name | Type | Default Value | Mandatory | Description |
| --------------- | ------ | ---------- | ---- | ---------------------------------------- |
| flex-direction | string | row | No | Main axis direction of the flex container, which defines how items are placed in the container. Available values are as follows:<br>- **column**: Items are placed vertically from top to bottom.<br>- **row**: Items are placed horizontally from left to right.|
| justify-content | string | flex-start | No | How items are aligned along the main axis of the flex container. Available values are as follows:<br>- **flex-start**: Items are packed toward the start edge of the container along the main axis.<br>- **flex-end**: Items are packed toward the end edge of the container along the main axis.<br>- **center**: Items are packed toward the center of the container along the main axis.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.<br>- **space-evenly**<sup>5+</sup>: Items are distributed within the container along the main axis, with even space between each two.|
| Name | Type | Default Value | Mandatory | Description |
| --------------- | ------ | ------------- | --------- | ------------------------------------------------------------ |
| flex-direction | string | row | No | Main axis direction of the container. Available values are as follows:<br>- **column**: Items are placed vertically from top to bottom.<br>- **row**: Items are placed horizontally from left to right. |
| justify-content | string | flex-start | No | How items are aligned along the main axis of the current row in the container. Available values are as follows:<br>- **flex-start**: Items are packed towards the start row.<br>- **flex-end**: Items are packed towards the end row.<br>- **center**: Items are centered along the row.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.<br>- **space-evenly**<sup>5+</sup>: Items are arranged with even space between each two. |
## Events
In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported.
In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported.
| Name | Name | Description |
| ------------- | ---------------------------------- | ---------------------------------------- |
| groupclick | { groupid: string } | Triggered when a group is clicked.<br>**groupid**: ID of the group that is clicked. |
| groupcollapse | { groupid: string } | Triggered when a group is collapsed.<br>**groupid**: ID of the group that is collapsed.<br>If the parameter is not carried or **groupid** is left empty, all groups are collapsed.|
| groupexpand | { groupid: string } | Triggered when a group is expanded.<br>**groupid**: ID of the group that is expanded.<br>If the parameter is not carried or **groupid** is left empty, all groups are expanded.|
| Name | Parameter | Description |
| ------------- | ------------------- | ------------------------------------------------------------ |
| groupclick | { groupid: string } | Triggered when a group is clicked.<br>**groupid**: ID of the group that is clicked. |
| groupcollapse | { groupid: string } | Triggered when a group is collapsed.<br>**groupid**: ID of the group collapsed.<br>If the parameter is not carried or **groupid** is left empty, all groups are collapsed. |
| groupexpand | { groupid: string } | Triggered when a group is expanded.<br>**groupid**: ID of the group expanded.<br>If the parameter is not carried or **groupid** is left empty, all groups are expanded. |
## Methods
Methods in [Universal Methods](js-components-common-methods.md) are supported.
The [universal methods](../arkui-js/js-components-common-methods.md) are supported.
## Example
```
```html
<!-- xxx.hml -->
<div class="doc-page">
<list style="width: 100%;" id="mylist">
......@@ -86,6 +92,9 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported.
</list-item-group>
</list>
</div>
```
```css
/* xxx.css */
.doc-page {
flex-direction: column;
......@@ -111,12 +120,16 @@ Methods in [Universal Methods](js-components-common-methods.md) are supported.
align-items: center;
width:100%;
}
```
```js
// xxx.js
import prompt from '@system.prompt';
export default {
data: {
direction: 'column',
list: []
list: [],
listAdd: []
},
onInit() {
this.list = []
......@@ -157,4 +170,4 @@ export default {
}
```
![img](figures/list6.gif)
\ No newline at end of file
![list6](figures/list6.gif)
# stepper
> **NOTE**
>
> This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version.
The **\<stepper>** component provides a step navigator. When multiple steps are required to complete a task, you can use the **\<stepper>** component to navigate your users through the whole process.
## Required Permissions
None
## Child Components
Only the **\<stepper-item>** component is supported.
> ![img](https://gitee.com/openharmony/docs/raw/OpenHarmony-3.1-Release/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:** Steps in the **\<stepper>** are sorted according to the sequence of its **\<stepper-item>** child components.
> **NOTE**
>
> Steps in the **\<stepper>** are sorted according to the sequence of its **\<stepper-item>** child components.
## Attributes
In addition to the attributes in [Universal Attributes](js-components-common-attributes.md), the following attributes are supported.
## Attributes
In addition to the [universal attributes](../arkui-js/js-components-common-attributes.md), the following attributes are supported.
| Name | Type | Default Value | Description |
| ----- | ------ | ---- | ------------------------------ |
| index | number | - | Index of the **\<stepper-item>** child component that is currently displayed.|
| Name | Type | Default Value | Description |
| ----- | ------ | ------------- | ------------------------------------------------------------ |
| index | number | - | Index of the **\<stepper-item>** child component that is currently displayed. |
## Styles
Styles in [Universal Styles](js-components-common-styles.md) are supported.
The [universal styles](../arkui-js/js-components-common-styles.md) are supported.
> ![img](https://gitee.com/openharmony/docs/raw/OpenHarmony-3.1-Release/en/application-dev/public_sys-resources/icon-note.gif) **NOTE:** By default, the **\<stepper>** component fills entire space of its container. To optimize user experience, it is recommended that the container should be as large as the application window in size, or should be the root component.
> **NOTE**
>
> By default, the **\<stepper>** component fills entire space of its container. To optimize user experience, it is recommended that the container should be as large as the application window in size, or should be the root component.
## Events
In addition to the events in [Universal Events](js-components-common-events.md), the following events are supported.
## Events
In addition to the [universal events](../arkui-js/js-components-common-events.md), the following events are supported.
| Name | Parameter | Description |
| ------ | ---------------------------------------- | ---------------------------------------- |
| finish | - | Triggered when the last step on the navigator is complete. |
| skip | - | Triggered when users click the skip button, which works only if you have called **setNextButtonStatus** method to allow users to skip all steps.|
| change | { prevIndex: prevIndex, index: index} | Triggered when users click the left or right (text) button of the step navigator to switch between steps. **prevIndex** indicates the index of the previous step, and **index** indicates that of the current step.|
| next | { index: index, pendingIndex: pendingIndex } | Triggered when users click the next (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the next step to go.|
| back | { index: index, pendingIndex: pendingIndex } | Triggered when users click the previous (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in Object:{ **{pendingIndex:*** pendingIndex***}** format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the previous step.|
| Name | Parameter | Description |
| ------ | -------------------------------------------- | ------------------------------------------------------------ |
| finish | None | Triggered when the last step on the navigator is complete. |
| skip | None | Triggered when users click the skip button, which works only if you have called **setNextButtonStatus** method to allow users to skip all steps. |
| change | { prevIndex: prevIndex, index: index} | Triggered when users click the left or right (text) button of the step navigator to switch between steps. **prevIndex** indicates the index of the previous step, and **index** indicates that of the current step. |
| next | { index: index, pendingIndex: pendingIndex } | Triggered when users click the next (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in **{pendingIndex:** pendingIndex**}** format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the next step to go. |
| back | { index: index, pendingIndex: pendingIndex } | Triggered when users click the previous (text) button. **index** indicates the index of the current step, and **pendingIndex** indicates that of the step to go. The return value is in Object:{ **{pendingIndex:** pendingIndex**}** format. You can use **pendingIndex** to specify a **\<stepper-item>** child component as the previous step. |
## Methods
In addition to the methods in [Universal Methods](js-components-common-methods.md), the following events are supported.
In addition to the [universal methods](../arkui-js/js-components-common-methods.md), the following methods are supported.
| Name | Parameter | Description |
| ------------------- | ---------------------------------------- | ---------------------------------------- |
| setNextButtonStatus | { status: string, label: label } | Sets the status of the next (text) button in this step navigator. Available **status** values are as follows:<br>- **normal**: The next button is displayed normally and can navigate users to the next step when it is clicked.<br>- **disabled**: The next button is grayed out and unavailable.<br>- **waiting**: The next button is not displayed, and a process bar is displayed instead.<br>- **skip**: The skip button is displayed to allow users to skip all remaining steps.|
| Name | Parameter | Description |
| ------------------- | -------------------------------- | ------------------------------------------------------------ |
| setNextButtonStatus | { status: string, label: label } | Sets the status of the next (text) button in this step navigator. Available **status** values are as follows: <br>- **normal**: The next button is displayed normally and can navigate users to the next step when it is clicked. <br>- **disabled**: The next button is grayed out and unavailable. <br>- **waiting**: The next button is not displayed, and a process bar is displayed instead. <br>- **skip**: The skip button is displayed to allow users to skip all remaining steps. |
## Example
```
```html
<!-- xxx.hml -->
<div class = "container">
<stepper class="stepper" id="mystepper" index="0" onnext="nextclick" onback="backclick">
......@@ -78,6 +87,9 @@ In addition to the methods in [Universal Methods](js-components-common-methods.m
</stepper-item>
</stepper>
</div>
```
```css
/* xxx.css */
.container {
margin-top: 20px;
......@@ -86,6 +98,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.m
height: 300px;
}
.stepperItem {
width: 100%;
flex-direction: column;
align-items: center;
}
......@@ -99,6 +112,9 @@ In addition to the methods in [Universal Methods](js-components-common-methods.m
margin-top: 30px;
justify-content: center;
}
```
```js
// xxx.js
export default {
data: {
......@@ -139,4 +155,4 @@ export default {
}
```
![img](figures/en-us_image_0000001127125114.gif)
\ No newline at end of file
![en-us_image_0000001127125114](figures/en-us_image_0000001127125114.gif)
......@@ -25,7 +25,7 @@ Video(value: {src?: string | Resource, currentProgressRate?: number | string | P
| Name | Type | Mandatory| Description |
| ------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| src | string \| [Resource](ts-types.md#resource) | No | Path of the video source, which can be a local path or a URL.<br>The video resources can be stored in the **video** or **rawfile** folder under **resources**.<br>The path can include a **dataability://** prefix, which is used to access the video path provided by a Data ability. For details about the path, see [Data Ability Development](../../ability/fa-dataability.md).<br>**NOTE**<br>The supported video formats are MP4, MKV, WebM, and TS. |
| currentProgressRate | number \| string \| PlaybackSpeed<sup>8+</sup> | No | Video playback speed.<br>**NOTE**<br>The value of the number type can only be **0.75**, **1.0**, **1.25**, **1.75**, or **2.0**.<br>Default value: **1.0** \| PlaybackSpeed.Speed_Forward_1_00_X |
| currentProgressRate | number \| PlaybackSpeed<sup>8+</sup> | No | Video playback speed.<br>**NOTE**<br>The value of the number type can only be **0.75**, **1.0**, **1.25**, **1.75**, or **2.0**.<br>Default value: **1.0** \| PlaybackSpeed.Speed_Forward_1_00_X |
| previewUri | string \| PixelMap<sup>8+</sup> \| [Resource](ts-types.md#resource) | No | Path of the preview image. |
| controller | [VideoController](#videocontroller) | No | Controller. |
......@@ -181,7 +181,7 @@ struct VideoCreateComponent {
console.error('onFinish');
})
.onError(() => {
console.error('onFinish');
console.error('onError');
})
.onPrepared((e) => {
console.error('onPrepared is ' + e.duration);
......
# &lt;button&gt; Development
# \<button> Development
The **\<button>** component can be used to set a capsule, circle, text, arc, or download button. For details, see [button](../reference/arkui-js/js-components-basic-button.md).
The **&lt;button&gt;** component can be used to set a capsule, circle, text, arc, or download button. For details, see [button](../reference/arkui-js/js-components-basic-button.md).
## Creating a \<button> Component
## Creating a &lt;button&gt; Component
Create a **\<button>** component in the .hml file under **pages/index**.
Create a **&lt;button&gt;** component in the .hml file under **pages/index**.
```
```html
<!-- xxx.hml -->
<div class="container">
<button type="capsule" value="Capsule button"></button>
</div>
```
```
```css
/* xxx.css */
.container {
width: 100%;
......@@ -34,11 +31,10 @@ Create a **&lt;button&gt;** component in the .hml file under **pages/index**.
## Setting the Button Type
Set the **type** attribute of the **&lt;input&gt;** component to **button**, **date**, or any of the supported values.
Set the **type** attribute of the **\<button>** component to **circle**, **text**, or any other supported value.
```
```html
<!-- xxx.hml -->
<div class="container">
<button class="circle" type="circle" >+</button>
......@@ -47,8 +43,7 @@ Set the **type** attribute of the **&lt;input&gt;** component to **button**, **d
```
```
```css
/* xxx.css */
.container {
width: 100%;
......@@ -78,20 +73,14 @@ Set the **type** attribute of the **&lt;input&gt;** component to **button**, **d
![en-us_image_0000001222967744](figures/en-us_image_0000001222967744.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - For capsule buttons, border-related styles are not supported.
>
> - For circle buttons, text-related styles are not supported.
> **NOTE**
>
> - For text buttons, the text size is adaptive, and **radius**, **width**, and **height** cannot be set. The **background-color** style is not supported when the background is completely transparent.
>
> - If the icon used by the **&lt;button&gt;** component is from the cloud, you must declare the **ohos.permission.INTERNET** permission in the **config.json** file under the **resources** folder.
>If the icon used by the **\<button>** component is from the cloud, you must declare the **ohos.permission.INTERNET** permission in the **config.json** file under the **resources** folder.
Sample code for declaring the **ohos.permission.INTERNET** permission in the **config.json** file under the **resources** folder:
```
<!-- config.json -->
"module": {
......@@ -104,20 +93,20 @@ Sample code for declaring the **ohos.permission.INTERNET** permission in the **c
## Showing the Download Progress
Add the **progress** method to the **&lt;button&gt;** component to display the download progress in real time.
Add the **progress** method to the **\<button>** component to display the download progress in real time.
```
```html
<!-- xxx.hml -->
<div class="container">
<button class="button download" type="download" id="download-btn" onclick="setProgress">{{downloadText}}</button>
</div>
```
```
```css
/* xxx.css */
.container {
width: 100%;
height: 100%;
background-color: #F1F3F5;
flex-direction: column;
align-items: center;
......@@ -130,8 +119,7 @@ Add the **progress** method to the **&lt;button&gt;** component to display the d
}
```
```
```js
// xxx.js
import prompt from '@system.prompt';
export default {
......@@ -141,7 +129,7 @@ export default {
isPaused: true,
intervalId : null,
},
star(){
start(){
this.intervalId = setInterval(()=>{
if(this.percent <100){
this.percent += 1;
......@@ -166,7 +154,7 @@ export default {
prompt.showToast({
message: "Started Downloading"
})
this.star();
this.start();
this.isPaused = false;
}else{
prompt.showToast({
......@@ -181,7 +169,7 @@ export default {
![en-us_image_0000001223287652](figures/en-us_image_0000001223287652.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
>
> The **setProgress** method supports only buttons of the download type.
......@@ -191,8 +179,7 @@ export default {
Switch between the button types for different types of text.
```
```html
<!-- xxx.hml -->
<div class="container">
<div class="input-item">
......@@ -210,8 +197,7 @@ Switch between the button types for different types of text.
```
```
```css
/* xxx.css */
.container {
flex-direction: column;
......@@ -258,8 +244,7 @@ Switch between the button types for different types of text.
```
```
```js
// xxx.js
export default {
data: {
......
# &lt;image&gt; Development
# \<image> Development
The **\<image>** component is used to render and display images. For details, see [image](../reference/arkui-js/js-components-basic-image.md).
The **&lt;image&gt;** component is used to render and display images. For details, see [image](../reference/arkui-js/js-components-basic-image.md).
## Creating an \<image> Component
## Creating an &lt;image&gt; Component
Create an **&lt;image&gt;** component in the .hml file under **pages/index**.
```
Create an **\<image>** component in the .hml file under **pages/index**.
```html
<!-- index.hml -->
<div class="container">
<image style="height: 30%;" src="common/images/bg-tv.jpg"> </image>
</div>
```
```
```css
/* xxx.css */
.container {
width: 100%;
......@@ -33,11 +30,10 @@ The **&lt;image&gt;** component is used to render and display images. For detail
## Setting the Image Style
Set the **width**, **height**, and **object-fit** attributes to define the width, height, and scale type of an image.
Set the **width**, **height**, and **object-fit** attributes to define the width, height, and scale type of the image.
```
```html
<!-- index.hml -->
<div class="container">
<image src="common/images/bg-tv.jpg"> </image>
......@@ -45,8 +41,7 @@ Set the **width**, **height**, and **object-fit** attributes to define the width
```
```
```css
/* xxx.css */
.container {
width: 100%;
......@@ -63,21 +58,18 @@ image{
border-radius: 20px;
object-fit: contain;
match-text-direction:true;
}
```
![en-us_image_0000001222807796](figures/en-us_image_0000001222807796.png)
## Loading Images
When an image is successfully loaded, the **complete** event is triggered, and the loaded image is returned. If an exception occurs during image loading, the **error** event is triggered, and the image loading failure is printed.
## Loading the Image
When the image is successfully loaded, the **complete** event is triggered, and the loaded image is returned. If an exception occurs during image loading, the **error** event is triggered, and the image loading failure log is printed.
```
```html
<!-- index.hml -->
<div class="container" >
<div>
......@@ -89,8 +81,7 @@ When an image is successfully loaded, the **complete** event is triggered, and t
</div>
```
```
```css
/* xxx.css */
.container{
width: 100%;
......@@ -108,14 +99,13 @@ When an image is successfully loaded, the **complete** event is triggered, and t
}
```
```
/* index.js */
```js
// index.js
import prompt from '@system.prompt';
export default {
imageComplete(i,e){
prompt.showToast({
message: "Image "+i+"'s width"+ e.width+"----Image "+i+"'s height"+e.height,
message: "image "+i+"'s width"+ e.width+"----image "+i+"'s height"+e.height,
duration: 3000,
})
},
......@@ -130,19 +120,19 @@ export default {
}
```
![en-us_image_images.gif ](figures/en-us_image_images.gif )
![en-us_image_images](figures/en-us_image_images.gif)
## Example Scenario
In this example you touch and hold an image to gradually hide it. After the image is completely hidden, it will show in its original setting. Set a **setInterval** timer to change the image opacity at a specified interval so that it is hidden gradually. When the opacity changes to **0**, the timer is cleared and the opacity is set to **1**.
```
```html
<!-- index.hml -->
<div class="page-container">
<div class="content">
<div class="image-container">
<image class="testimage" src="{{testuri}}" style="display:{{displaytype}};opacity:{{imageopacity}};" onclick="changedisplaytype" onlongpress="changeopacity"> </image>
<image class="testimage" src="{{testuri}}" style="opacity:{{imageopacity}};" onlongpress="changeopacity"> </image>
</div>
<div class="text-container">
<text style="font-size: 37px;font-weight:bold;color:orange;text-align: center;width: 100%;">Touch and hold the image</text>
......@@ -151,8 +141,7 @@ In this example you touch and hold an image to gradually hide it. After the imag
</div>
```
```
```css
/* xxx.css */
.page-container {
width: 100%;
......@@ -186,9 +175,8 @@ In this example you touch and hold an image to gradually hide it. After the imag
}
```
```
/* index.js */
```js
// index.js
import prompt from '@system.prompt';
export default {
data: {
......
# &lt;picker&gt; Development
# \<picker> Development
The **\<picker>** component supports common, date, time, data and time, and multi-column text selectors. For details, see [picker](../reference/arkui-js/js-components-basic-picker.md).
The **&lt;picker&gt;** component supports common, date, time, data and time, and multi-column text selectors. For details, see [picker](../reference/arkui-js/js-components-basic-picker.md).
## Creating a \<picker> Component
## Creating a &lt;picker&gt; Component
Create a **\<picker>** component in the .hml file under **pages/index**.
Create a **&lt;picker&gt;** component in the .hml file under **pages/index**.
```
<!-- index.hml -->
```html
<!-- xxx.hml -->
<div class="container">
<picker>
picker
</picker>
<div>
<picker> picker </picker>
</div>
```
```
/* index.css */
```css
/* xxx.css */
.container {
width: 100%;
height: 100%;
height: 100%;
flex-direction: column;
justify-content: center;
align-items: center;
......@@ -36,20 +31,18 @@ Create a **&lt;picker&gt;** component in the .hml file under **pages/index**.
## Setting the Picker Type
Set the **type** attribute of the **&lt;picker&gt;** component. For example, set it to **date**.
Set the **type** attribute of the **\<picker>** component. For example, set it to **date**.
```
<!-- index.hml -->
```html
<!-- xxx.hml -->
<div class="container">
<picker id="picker_text" type="text" value="{{textvalue}}"range="{{rangetext}}" class="pickertext" ></picker>
<picker id="picker_date" type="date" value="{{datevalue}}" lunarswitch="true" start="2002-2-5" end="2030-6-5" class="pickerdate"></picker>
</div>
```
```
/* index.css */
```css
/* xxx.css */
.container {
width: 100%;
height: 100%;
......@@ -63,8 +56,7 @@ Set the **type** attribute of the **&lt;picker&gt;** component. For example, set
}
```
```
```js
// xxx.js
export default {
data: {
......@@ -77,27 +69,25 @@ export default {
![en-us_image_0000001267647893](figures/en-us_image_0000001267647893.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> - When setting the value range of a common selector, you must use the data binding mode.
> **NOTE**
>
> When setting the value range of a common selector, you must use the data binding mode.
## Setting the Time Format
Set the **hours** attribute to specify the time format used by the time selector. Available values include **12** and **24**, indicating the 12-hour format and 24-hour format, respectively.
Set the **hours** attribute to specify the time format used by the time picker. Available values include **12** and **24**, indicating the 12-hour format and 24-hour format, respectively.
```
<!-- index.hml -->
```html
<!-- xxx.hml -->
<div class="container">
<picker id="picker_time" type="time" value="12-hour format" hours="12" onchange="timeonchange" class="pickertime"></picker>
<picker id="picker_time" type="time" value="24-hour format" hours="24" onchange="timeonchange" class="pickertime"></picker>
</div>
```
```
/* index.css */
```css
/* xxx.css */
.container {
width: 100%;
height: 100%;
......@@ -115,7 +105,7 @@ Set the **hours** attribute to specify the time format used by the time selector
![en-us_image_0000001222807808](figures/en-us_image_0000001222807808.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:**
> **NOTE**
> - When **hours** is set to **12**, the time is displayed in 12-hour format and distinguished by a.m. and p.m.
>
> - When **hours** is set to **24**, the time is displayed in 24-hour format.
......@@ -123,20 +113,18 @@ Set the **hours** attribute to specify the time format used by the time selector
## Adding Response Events
To confirm and cancel selection, add **change** and **cancel** events.
Add the **change** event to confirm selection and the **cancel** event to cancel selection.
```
<!-- index.hml -->
```html
<!-- xxx.hml -->
<div class="container">
<picker id="picker_multi" type="multi-text" value="{{multitextvalue}}" columns="3" range="{{multitext}}" selected="
{{multitextselect}}" onchange="multitextonchange" oncancel="multitextoncancel" class="pickermuitl"></picker>
</div>
```
```
/* index.css */
```css
/* xxx.css */
.container {
width: 100%;
height: 100%;
......@@ -154,8 +142,7 @@ To confirm and cancel selection, add **change** and **cancel** events.
}
```
```
```js
// xxx.js
import prompt from '@system.prompt';
export default {
......@@ -180,12 +167,11 @@ export default {
## Example Scenario
Implement a health check-in application by using the **&lt;picker&gt;** component.
Implement a health check-in application by using the **\<picker>** component.
```
<!-- index.hml -->
```html
<!-- xxx.hml -->
<div class="doc-page">
<text class="title">Health check-in</text>
<div class="out-container">
......@@ -215,9 +201,8 @@ Implement a health check-in application by using the **&lt;picker&gt;** componen
```
```
/* index.css */
```css
/* xxx.css */
.doc-page {
flex-direction: column;
background-color: #F1F3F5;
......@@ -259,8 +244,7 @@ Implement a health check-in application by using the **&lt;picker&gt;** componen
```
```
```js
// xxx.js
import pmt from '@system.prompt'
export default {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册