提交 9db778f7 编写于 作者: 张修齐 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/docs into master

......@@ -34,40 +34,52 @@
1. To obtain data from a type of sensor, configure the requested permissions in the **config.json** file.
```
"reqPermissions":[
{
"name":"ohos.permission.ACCELEROMETER",
"reason"":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.GYROSCOPE",
"reason"":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.ACTIVITY_MOTION",
"reason"":"ACTIVITY_MOTION_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.READ_HEALTH_DATA",
"reason"":"HEALTH_DATA_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
]
"reqPermissions": [
{
"name": "ohos.permission.ACCELEROMETER",
"reason": "",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GYROSCOPE",
"reason": "",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACTIVITY_MOTION",
"reason": "ACTIVITY_MOTION_TEST",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.READ_HEALTH_DATA",
"reason": "HEALTH_DATA_TEST",
"usedScene": {
"ability": [
"sensor.index.MainAbility",
".MainAbility"
],
"when": "inuse"
}
}
]
```
2. Subscribe to data changes of a type of sensor.
......@@ -75,7 +87,7 @@
```
import sensor from "@ohos.sensor"
sensor.on(sensor.sensorType.SENSOR_TYPE_ACCELEROMETER,function(data){
console.info("Subscription succeeded. data = "+ data); // The call is successful, and the obtained sensor data is printed.
console.info("Subscription succeeded. data = " + data); // The call is successful, and the obtained sensor data is printed.
}
);
```
......@@ -127,4 +139,4 @@
The following sample is provided to help you better understand how to develop sensors:
- [`Sensor`: sensor (eTS, API 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor)
- [`Sensor`: sensor (eTS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/device/Sensor)
......@@ -59,6 +59,7 @@
- Bundle Management
- [@ohos.bundle](js-apis-Bundle.md)
- [@ohos.bundle.defaultAppManager](js-apis-bundle-defaultAppManager.md)
- [@ohos.bundleState](js-apis-deviceUsageStatistics.md)
- [@ohos.zlib](js-apis-zlib.md)
- bundle/[AbilityInfo](js-apis-bundle-AbilityInfo.md)
......@@ -108,6 +109,7 @@
- [@ohos.configPolicy](js-apis-config-policy.md)
- [@ohos.enterpriseDeviceManager](js-apis-enterprise-device-manager.md)
- [@ohos.EnterpriseAdminExtensionAbility](js-apis-EnterpriseAdminExtensionAbility.md)
- Security
......@@ -173,6 +175,7 @@
- [@ohos.hichecker](js-apis-hichecker.md)
- [@ohos.hidebug](js-apis-hidebug.md)
- [@ohos.hilog](js-apis-hilog.md)
- [@ohos.hiSysEvent](js-apis-hisysevent.md)
- [@ohos.hiTraceChain](js-apis-hitracechain.md)
- [@ohos.hiTraceMeter](js-apis-hitracemeter.md)
- [@ohos.inputMethod](js-apis-inputmethod.md)
......@@ -192,13 +195,13 @@
- [@ohos.geolocation](js-apis-geolocation.md)
- [@ohos.multimodalInput.inputConsumer](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.multimodalInput.inputEventClient](js-apis-inputeventclient.md)
- [@ohos.multimodalInput.inputMonitor](js-apis-inputmonitor.md)
- [@ohos.multimodalInput.inputEvent](js-apis-inputevent.md)
- [@ohos.multimodalInput.keyCode](js-apis-keycode.md)
- [@ohos.multimodalInput.keyEvent](js-apis-keyevent.md)
- [@ohos.multimodalInput.mouseEvent](js-apis-mouseevent.md)
- [@ohos.multimodalInput.ToucEvent](js-apis-touchevent.md)
- [@ohos.multimodalInput.touchEvent](js-apis-touchevent.md)
- [@ohos.power](js-apis-power.md)
- [@ohos.runningLock](js-apis-runninglock.md)
- [@ohos.sensor](js-apis-sensor.md)
......
# EnterpriseAdminExtentionAbility
The **EnterpriseAdminExtentionAbility** module provides APIs for Extension abilities of enterprise administrators.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import EnterpriseAdminExtentionAbility from '@ohos.EnterpriseAdminExtentionAbility'
```
## EnterpriseAdminExtentionAbility.onAdminEnabled
onAdminEnabled(): void
Called when an enterprise administrator is enabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**Example**
```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() {
}
};
```
## EnterpriseAdminExtentionAbility.onAdminDisabled
onAdminDisabled(): void
Called when an enterprise administrator is disabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**Example**
```ts
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminDisabled() {
}
};
```
# AbilityManager
The **AbilityManager** module provides APIs for obtaining, adding, and modifying ability running information and state information.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications.
# Modules to Import
```js
import AbilityManager from '@ohos.application.abilityManager'
```
## AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
## updateConfiguration
updateConfiguration(config: Configuration, callback: AsyncCallback\<void>): void
Obtains the ability running information. This API uses an asynchronous callback to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | Configuration | Yes | New configuration.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var config = {
language: 'chinese'
}
abilitymanager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
```
## updateConfiguration
updateConfiguration(config: Configuration): Promise\<void>
Updates the configuration. This API uses a promise to return the result.
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| config | Configuration | Yes | New configuration.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<void> | Promise used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var config = {
language: 'chinese'
}
abilitymanager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
})
```
## getAbilityRunningInfos
getAbilityRunningInfos(callback: AsyncCallback\<Array\<AbilityRunningInfo>>): void
Obtains the ability running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getAbilityRunningInfos
getAbilityRunningInfos(): Promise\<Array\<AbilityRunningInfo>>
Obtains the ability running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getAbilityRunningInfos().then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data))
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err)
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void
Obtains the extension running information. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
| callback | AsyncCallback\<Array\<AbilityRunningInfo>> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var upperLimit = 0;
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
## getExtensionRunningInfos<sup>9+</sup>
getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>
Obtains the extension running information. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<Array\<AbilityRunningInfo>> | Promise used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
var upperLimit = 0;
abilitymanager.getExtensionRunningInfos(upperLimit).then((data) => {
console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
})
```
## getTopAbility<sup>9+</sup>
getTopAbility(callback: AsyncCallback\<ElementName>): void;
Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
| callback | AsyncCallback\<ElementName> | Yes | Callback used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getTopAbility((err,data) => {
console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
```
## getTopAbility<sup>9+</sup>
getTopAbility(): Promise\<ElementName>;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise\<ElementName>| Promise used to return the result. |
**Example**
```js
import abilitymanager from '@ohos.application.abilityManager';
abilitymanager.getTopAbility().then((data) => {
console.log("getTopAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getTopAbility err: " + err);
})
```
......@@ -42,7 +42,7 @@ Provides the ability information.
| labelId | number | Yes | No | Ability label ID. |
| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. |
| metaData<sup>8+</sup> | Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)> | Yes | No | Custom metadata of the ability. |
| metaData<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. |
| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. |
| enabled<sup>8+</sup> | boolean | Yes | No | Whether the ability is enabled. |
| supportWindowMode<sup>9+</sup> | Array\<[SupportWindowMode](js-apis-Bundle.md)> | Yes | No | Window modes supported by the ability. |
| maxWindowRatio<sup>9+</sup> | number | Yes | No | Maximum window ratio supported by the ability. |
......
# ApplicationInfo
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the application information.
## ApplicationInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------ |
| name | string | Yes | No | Application name. |
| description | string | Yes | No | Application description. |
| descriptionId | number | Yes | No | Application description ID. |
| systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. |
| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. |
| label | string | Yes | No | Application label. |
| labelId | string | Yes | No | Application label ID. |
| icon | string | Yes | No | Application icon. |
| iconId | string | Yes | No | Application icon ID. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used.|
| supportedModes | number | Yes | No | Running modes supported by the application. |
| moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. |
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. |
| moduleInfos | Array\<[ModuleInfo](js-apis-bundle-ModuleInfo.md)> | Yes | No | Application module information. |
| entryDir | string | Yes | No | Path for storing application files. |
| codePath<sup>8+</sup> | string | Yes | No | Installation directory of the application. |
| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | Yes | No | Custom metadata of the application. |
| metaData<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | Yes | No | Metadata of the application. |
| removable<sup>8+</sup> | boolean | Yes | No | Whether the application is removable. |
| accessTokenId<sup>8+</sup> | number | Yes | No | Access token ID of the application. |
| uid<sup>8+</sup> | number | Yes | No | UID of the application. |
| entityType<sup>8+</sup> | string | Yes | No | Entity type of the application. |
| fingerprint<sup>9+</sup> | string | Yes | No | Signing certificate fingerprint of the application, that is, the SHA-256 checksum of the signing certificate that you apply for for the application. |
| Name | Type | Readable| Writable| Description |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Application name. |
| description | string | Yes | No | Application description. |
| descriptionId | number | Yes | No | Application description ID. |
| systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. |
| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. |
| label | string | Yes | No | Application label. |
| labelId | string | Yes | No | Application label ID. |
| icon | string | Yes | No | Application icon. |
| iconId | string | Yes | No | Application icon ID. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
| supportedModes | number | Yes | No | Running modes supported by the application. |
| moduleSourceDirs | Array\<string> | Yes | No | Relative paths for storing application resources. |
| permissions | Array\<string> | Yes | No | Permissions required for accessing the application. |
| moduleInfos | Array\<[ModuleInfo](js-apis-bundle-ModuleInfo.md)> | Yes | No | Application module information. |
| entryDir | string | Yes | No | Path for storing application files. |
| codePath<sup>8+</sup> | string | Yes | No | Installation directory of the application. |
| metaData<sup>8+</sup> | Map\<string, Array\<[CustomizeData](js-apis-bundle-CustomizeData.md)>> | Yes | No | Custom metadata of the application. |
| metadata<sup>9+</sup> | Map\<string, Array\<[Metadata](js-apis-bundle-Metadata.md)>> | Yes | No | Metadata of the application. |
| removable<sup>8+</sup> | boolean | Yes | No | Whether the application is removable. |
| accessTokenId<sup>8+</sup> | number | Yes | No | Access token ID of the application. |
| uid<sup>8+</sup> | number | Yes | No | UID of the application. |
| entityType<sup>8+</sup> | string | Yes | No | Entity type of the application. |
| fingerprint<sup>9+</sup> | string | Yes | No | Signing certificate fingerprint of the application, that is, the SHA-256 checksum of the signing certificate that you request for the application.|
| appDistributionType<sup>9+</sup> | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType<sup>9+</sup> | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**.|
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the application bundle information.
## BundleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
......
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides custom metadata.
## CustomizeData
**System capability**: SystemCapability.BundleManager.BundleFramework
......
# ElementName
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the element name information.
## ElementName
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name | Type | Readable| Writable| Description |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| deviceId | string | Yes | Yes | Device ID. |
| bundleName | string | Yes | Yes | Bundle name of the application. |
| abilityName | string | Yes | Yes | Name of the ability. |
| uri | string | Yes | Yes | URI. |
| shortName | string | Yes | Yes | Short name of the ability. |
| moduleName<sup>9+</sup> | string | Yes | Yes | Name of the HAP file to which the ability belongs. |
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the Extension ability information.
## ExtensionAbilityInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
......@@ -25,7 +26,7 @@ Provides the Extension ability information.
| extensionAbilityType | bundle.ExtensionAbilityType | Yes | No | Type of the Extension ability. |
| permissions | Array\<string> | Yes | No | Permissions required for other applications to call the Extension ability.|
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | Yes | No | Application information of the Extension ability. |
| metaData | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the Extension ability. |
| metadata | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the Extension ability. |
| enabled | boolean | Yes | No | Whether the Extension ability is enabled. |
| readPermission | string | Yes | No | Permission required for reading the Extension ability data. |
| writePermission | string | Yes | No | Permission required for writing data to the Extension ability. |
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the HAP module information.
## HapModuleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
......@@ -35,4 +36,4 @@ Provides the HAP module information.
| mainElementName<sup>9+</sup> | string | Yes | No | Information about the main ability. |
| extensionAbilityInfo<sup>9+</sup> | Array\<[ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md)> | Yes | No | Information about the Extension ability.|
| metadata<sup>9+</sup> | Array\<[Metadata](js-apis-bundle-Metadata.md)> | Yes | No | Metadata of the ability. |
| hashValue<sup>9+</sup> | string | Yes | No | The hash value of the module. |
\ No newline at end of file
| hashValue<sup>9+</sup> | string | Yes | No | Hash value of the module. |
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the metadata information.
## Metadata
**System capability**: SystemCapability.BundleManager.BundleFramework
......
......@@ -2,14 +2,15 @@
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the module information of the application.
## ModuleInfo
**System capability**: SystemCapability.BundleManager.BundleFramework
......
# Camera Management
> **NOTE**<br/>
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
```js
import camera from '@ohos.multimedia.camera';
```
## Required Permissions
ohos.permission.CAMERA
## camera.getCameraManager
getCameraManager(context: Context, callback: AsyncCallback<CameraManager\>): void
......@@ -30,7 +27,7 @@ Obtains a **CameraManager** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.getCameraManager(context, (err, cameraManager) => {
if (err) {
console.error('Failed to get the CameraManager instance ${err.message}');
......@@ -62,7 +59,7 @@ Obtains a **CameraManager** instance. This API uses a promise to return the resu
**Example**
```
```js
camera.getCameraManager(context).then((cameraManager) => {
console.log('Promise returned with the CameraManager instance.');
})
......@@ -74,12 +71,12 @@ Enumerates the camera statuses.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ------------------------- | ------ | ------------ |
| CAMERA_STATUS_APPEAR | 0 | The camera exists. |
| CAMERA_STATUS_DISAPPEAR | 1 | The camera does not exist.|
| CAMERA_STATUS_AVAILABLE | 2 | The camera is ready. |
| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is not ready.|
| Name | Value | Description |
| ------------------------- | ---- | ------------ |
| CAMERA_STATUS_APPEAR | 0 | The camera exists. |
| CAMERA_STATUS_DISAPPEAR | 1 | The camera does not exist.|
| CAMERA_STATUS_AVAILABLE | 2 | The camera is ready. |
| CAMERA_STATUS_UNAVAILABLE | 3 | The camera is not ready.|
## CameraPosition
......@@ -88,11 +85,11 @@ Enumerates the camera positions.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| --------------------------- | ------ | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.|
| CAMERA_POSITION_BACK | 1 | Rear camera. |
| CAMERA_POSITION_FRONT | 2 | Front camera. |
| Name | Value | Description |
| --------------------------- | ---- | ---------------- |
| CAMERA_POSITION_UNSPECIFIED | 0 | Unspecified position.|
| CAMERA_POSITION_BACK | 1 | Rear camera. |
| CAMERA_POSITION_FRONT | 2 | Front camera. |
## CameraType
......@@ -100,13 +97,13 @@ Enumerates the camera types.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ----------------------- | ------ | ---------------- |
| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.|
| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera. |
| Name | Value | Description |
| ----------------------- | ---- | ---------------- |
| CAMERA_TYPE_UNSPECIFIED | 0 | Unspecified camera type.|
| CAMERA_TYPE_WIDE_ANGLE | 1 | Wide camera. |
| CAMERA_TYPE_ULTRA_WIDE | 2 | Ultra wide camera. |
| CAMERA_TYPE_TELEPHOTO | 3 | Telephoto camera. |
| CAMERA_TYPE_TRUE_DEPTH | 4 | True depth camera. |
## ConnectionType
......@@ -115,12 +112,22 @@ Enumerates the camera connection types.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------------- | ------ | ------------- |
| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. |
| Name | Value | Description |
| ---------------------------- | ---- | ------------- |
| CAMERA_CONNECTION_BUILT_IN | 0 | Built-in camera. |
| CAMERA_CONNECTION_USB_PLUGIN | 1 | Camera connected using USB.|
| CAMERA_CONNECTION_REMOTE | 2 | Remote camera. |
## Size
Defines the image size that can be used in previewing, photographing, and video recording.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Readable| Writable| Description |
| ------ | ------ | ---- | ---- | ------------ |
| height | string | Yes | Yes | Image height.|
| width | number | Yes | Yes | Image width.|
## CameraManager
......@@ -142,7 +149,7 @@ Obtains all cameras supported by the device. This API uses an asynchronous callb
**Example**
```
```js
cameraManager.getCameras((err, cameras) => {
if (err) {
console.error('Failed to get the cameras. ${err.message}');
......@@ -169,41 +176,32 @@ Obtains all cameras supported by the device. This API uses a promise to return t
**Example**
```
```js
cameraManager.getCameras().then((cameraArray) => {
console.log('Promise returned with an array of supported cameras: ' + cameraArray.length);
})
```
### Size
Size parameters. This interface used to get supported size for Preview + Photo + Video.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| height | number | Yes | Desired height of the Preview + Photo + Video. |
| width | number | Yes | Desired width of the Preview + Photo + Video.|
### createCameraInput
createCameraInput(cameraId: string, callback: AsyncCallback<CameraInput\>): void
Creates a **CameraInput** instance with the specified camera ID. This API uses an asynchronous callback to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value | Mandatory| Description |
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | ----------------------------------- |
| cameraId | string | Yes | Camera ID used to create the instance. |
| callback | AsyncCallback<[CameraInput](#camerainput)\> | Yes | Callback used to return the **CameraInput** instance.|
**Example**
```
```js
cameraManager.createCameraInput(cameraId, (err, cameraInput) => {
if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}');
......@@ -219,11 +217,13 @@ createCameraInput(cameraId: string): Promise<CameraInput\>
Creates a **CameraInput** instance with the specified camera ID. This API uses a promise to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Mandatory| Description |
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------ |
| cameraId | string | Yes | Camera ID used to create the instance.|
......@@ -235,7 +235,7 @@ Creates a **CameraInput** instance with the specified camera ID. This API uses a
**Example**
```
```js
cameraManager.createCameraInput(cameraId).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance');
})
......@@ -247,6 +247,8 @@ createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCal
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses an asynchronous callback to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
......@@ -259,7 +261,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED, (err, cameraInput) => {
if (err) {
console.error('Failed to create the CameraInput instance. ${err.message}');
......@@ -275,6 +277,8 @@ createCameraInput(position: CameraPosition, type: CameraType): Promise<CameraInp
Creates a **CameraInput** instance with the specified camera position and camera type. This API uses a promise to return the instance.
**Required permissions**: ohos.permission.CAMERA
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
......@@ -292,7 +296,7 @@ Creates a **CameraInput** instance with the specified camera position and camera
**Example**
```
```js
cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, camera.CameraType.CAMERA_TYPE_UNSPECIFIED).then((cameraInput) => {
console.log('Promise returned with the CameraInput instance.');
})
......@@ -302,7 +306,7 @@ cameraManager.createCameraInput(camera.CameraPosition.CAMERA_POSITION_BACK, came
on(type: 'cameraStatus', callback: AsyncCallback<CameraStatusInfo\>): void
Listens for camera status changes. This API uses a callback to return the camera status changes.
Listens for camera status changes. This API uses an asynchronous callback to return the camera status changes.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -315,7 +319,7 @@ Listens for camera status changes. This API uses a callback to return the camera
**Example**
```
```js
cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
if (err) {
console.error('Failed to get cameraStatus callback. ${err.message}');
......@@ -328,7 +332,7 @@ cameraManager.on('cameraStatus', (err, cameraStatusInfo) => {
## Camera
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, including camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera instance is returned, with camera-related metadata such as **cameraId**, **cameraPosition**, **cameraType**, and **connectionType**.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -341,7 +345,7 @@ After **[camera.getCameraManager](#cameragetcameramanager)** is called, a camera
**Example**
```
```js
async function getCameraInfo("cameraId") {
var cameraManager = await camera.getCameraManager();
var cameras = await cameraManager.getCameras();
......@@ -351,7 +355,6 @@ async function getCameraInfo("cameraId") {
var cameraType = cameraObj.cameraType;
var connectionType = cameraObj.connectionType;
}
```
## CameraStatusInfo
......@@ -386,7 +389,7 @@ Obtains the camera ID based on which this **CameraInput** instance is created. T
**Example**
```
```js
cameraInput.getCameraId((err, cameraId) => {
if (err) {
console.error('Failed to get the camera ID. ${err.message}');
......@@ -412,7 +415,7 @@ Obtains the camera ID based on which this **CameraInput** instance is created. T
**Example**
```
```js
cameraInput.getCameraId().then((cameraId) => {
console.log('Promise returned with the camera ID:' + cameraId);
})
......@@ -435,7 +438,7 @@ Checks whether the device has flash light. This API uses an asynchronous callbac
**Example**
```
```js
cameraInput.hasFlash((err, status) => {
if (err) {
console.error('Failed to check whether the device has flash light. ${err.message}');
......@@ -461,7 +464,7 @@ Checks whether the device has flash light. This API uses a promise to return the
**Example**
```
```js
cameraInput.hasFlash().then((status) => {
console.log('Promise returned with the flash light support status:' + status);
})
......@@ -484,7 +487,7 @@ Checks whether a specified flash mode is supported. This API uses an asynchronou
**Example**
```
```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the flash mode is supported. ${err.message}');
......@@ -516,7 +519,7 @@ Checks whether a specified flash mode is supported. This API uses a promise to r
**Example**
```
```js
cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO).then((status) => {
console.log('Promise returned with flash mode support status.' + status);
})
......@@ -544,7 +547,7 @@ Before setting the parameters, do the following checks:
**Example**
```
```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the flash mode ${err.message}');
......@@ -581,7 +584,7 @@ Before setting the parameters, do the following checks:
**Example**
```
```js
cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFlashMode.');
})
......@@ -603,7 +606,7 @@ Obtains the current flash mode. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getFlashMode((err, flashMode) => {
if (err) {
console.error('Failed to get the flash mode ${err.message}');
......@@ -629,7 +632,7 @@ Obtains the current flash mode. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getFlashMode().then((flashMode) => {
console.log('Promise returned with current flash mode : ' + flashMode);
})
......@@ -652,7 +655,7 @@ Checks whether a specified focus mode is supported. This API uses an asynchronou
**Example**
```
```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO, (err, status) => {
if (err) {
console.error('Failed to check whether the focus mode is supported. ${err.message}');
......@@ -680,11 +683,11 @@ Checks whether a specified focus mode is supported. This API uses a promise to r
| Type | Description |
| ----------------- | ----------------------------------------------------------- |
| Promise<boolean\> | Promise used to return the flash mode support status. The value **true** means that the specified focus mode is supported.|
| Promise<boolean\> | Promise used to return the focus mode support status. The value **true** means that the specified focus mode is supported.|
**Example**
```
```js
cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_AUTO).then((status) => {
console.log('Promise returned with focus mode support status.' + status);
})
......@@ -709,7 +712,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO, (err) => {
if (err) {
console.error('Failed to set the focus mode ${err.message}');
......@@ -743,7 +746,7 @@ Before setting the focus mode, use **[isFocusModeSupported](#isfocusmodesupporte
**Example**
```
```js
cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_AUTO).then(() => {
console.log('Promise returned with the successful execution of setFocusMode.');
})
......@@ -765,7 +768,7 @@ Obtains the current focus mode. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getFocusMode((err, afMode) => {
if (err) {
console.error('Failed to get the focus mode ${err.message}');
......@@ -791,7 +794,7 @@ Obtains the current focus mode. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getFocusMode().then((afMode) => {
console.log('Promise returned with current focus mode : ' + afMode);
})
......@@ -813,7 +816,7 @@ Obtains the zoom ratio range. This API uses an asynchronous callback to return t
**Example**
```
```js
cameraInput.getZoomRatioRange((err, zoomRatioRange) => {
if (err) {
console.error('Failed to get the zoom ratio range. ${err.message}');
......@@ -839,7 +842,7 @@ Obtains the zoom ratio range. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getZoomRatioRange().then((zoomRatioRange) => {
console.log('Promise returned with zoom ratio range: ' + zoomRatioRange.length);
})
......@@ -862,7 +865,7 @@ Sets a zoom ratio. This API uses an asynchronous callback to return the result.
**Example**
```
```js
cameraInput.setZoomRatio(1, (err) => {
if (err) {
console.error('Failed to set the zoom ratio value ${err.message}');
......@@ -894,7 +897,7 @@ Sets a zoom ratio. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.setZoomRatio(1).then(() => {
console.log('Promise returned with the successful execution of setZoomRatio.');
})
......@@ -916,7 +919,7 @@ Obtains the current zoom ratio. This API uses an asynchronous callback to return
**Example**
```
```js
cameraInput.getZoomRatio((err, zoomRatio) => {
if (err) {
console.error('Failed to get the zoom ratio ${err.message}');
......@@ -942,7 +945,7 @@ Obtains the current zoom ratio. This API uses a promise to return the result.
**Example**
```
```js
cameraInput.getZoomRatio().then((zoomRatio) => {
console.log('Promise returned with current zoom ratio : ' + zoomRatio);
})
......@@ -964,7 +967,7 @@ Releases this **CameraInput** instance. This API uses an asynchronous callback t
**Example**
```
```js
cameraInput.release((err) => {
if (err) {
console.error('Failed to release the CameraInput instance ${err.message}');
......@@ -990,7 +993,7 @@ Releases this **CameraInput** instance. This API uses a promise to return the re
**Example**
```
```js
cameraInput.release().then(() => {
console.log('Promise returned to indicate that the CameraInput instance is released successfully.');
})
......@@ -1000,7 +1003,7 @@ cameraInput.release().then(() => {
on(type: 'focusStateChange', callback: AsyncCallback<FocusState\>): void
Listens for focus state changes. This API uses a callback to return the focus state changes.
Listens for focus state changes. This API uses an asynchronous callback to return the focus state changes.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -1013,7 +1016,7 @@ Listens for focus state changes. This API uses a callback to return the focus st
**Example**
```
```js
cameraInput.on('focusStateChange', (focusState) => {
console.log('Focus state : ' + focusState);
})
......@@ -1029,40 +1032,39 @@ Listens for **CameraInput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------------- |
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :----------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the camera input error event.|
| callback | ErrorCallback<CameraInputError\> | Yes | Callback used to return the capture input errors. |
| callback | ErrorCallback<[CameraInputError](#camerainputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
cameraInput.on('error', (cameraInputError) => {
console.log('Camera input error code: ' + cameraInputError.code);
})
```
## CameraInputErrorCode
## CameraInputErrorCode
Enumerates the CameraInput error code.
Enumerates the **CameraInput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN | -1 | Unknown error.|
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## CameraInputError
## CameraInputError
Camera input error object which extends **Error** interface.
Defines a **CameraInput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name| Type | Description |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CameraInputErrorCode](#camerainputerrorcode) | **CameraInput** error code.|
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [CameraInputErrorCode](#camerainputerrorcode) | Used to get error code in CameraInput on('error') callback|
## FlashMode
......@@ -1070,12 +1072,12 @@ Enumerates the flash modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| FLASH_MODE_CLOSE | 0 | The flash is off.|
| FLASH_MODE_OPEN | 1 | The flash is on.|
| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.|
| Name | Value | Description |
| ---------------------- | ---- | ------------ |
| FLASH_MODE_CLOSE | 0 | The flash is off.|
| FLASH_MODE_OPEN | 1 | The flash is on.|
| FLASH_MODE_AUTO | 2 | The flash mode is auto, indicating that the flash fires automatically depending on the shooting conditions.|
| FLASH_MODE_ALWAYS_OPEN | 3 | The flash is steady on.|
## FocusMode
......@@ -1083,12 +1085,12 @@ Enumerates the focus modes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| -------------------------- | ------ | ------------------ |
| FOCUS_MODE_MANUAL | 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.|
| FOCUS_MODE_AUTO | 2 | Auto focus. |
| FOCUS_MODE_LOCKED | 3 | Locked focus. |
| Name | Value | Description |
| -------------------------- | ---- | ------------------ |
| FOCUS_MODE_MANUAL | 0 | Manual focus. |
| FOCUS_MODE_CONTINUOUS_AUTO | 1 | Continuous auto focus.|
| FOCUS_MODE_AUTO | 2 | Auto focus. |
| FOCUS_MODE_LOCKED | 3 | Locked focus. |
## FocusState
......@@ -1096,11 +1098,11 @@ Enumerates the focus states.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| --------------------- | ------ | ------------ |
| FOCUS_STATE_SCAN | 0 | Scanning. |
| FOCUS_STATE_FOCUSED | 1 | Focused.|
| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.|
| Name | Value | Description |
| --------------------- | ---- | ------------ |
| FOCUS_STATE_SCAN | 0 | Scanning. |
| FOCUS_STATE_FOCUSED | 1 | Focused.|
| FOCUS_STATE_UNFOCUSED | 2 | Unfocused.|
## camera.createCaptureSession
......@@ -1119,7 +1121,7 @@ Creates a **CaptureSession** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.createCaptureSession((context), (err, captureSession) => {
if (err) {
console.error('Failed to create the CaptureSession instance. ${err.message}');
......@@ -1151,7 +1153,7 @@ Creates a **CaptureSession** instance. This API uses a promise to return the ins
**Example**
```
```js
camera.createCaptureSession(context).then((captureSession) => {
console.log('Promise returned with the CaptureSession instance');
})
......@@ -1177,7 +1179,7 @@ Starts configuration for this **CaptureSession** instance. This API uses an asyn
**Example**
```
```js
captureSession.beginConfig((err) => {
if (err) {
console.error('Failed to start the configuration. ${err.message}');
......@@ -1204,7 +1206,7 @@ Starts configuration for this **CaptureSession** instance. This API uses a promi
**Example**
```
```js
captureSession.beginConfig().then(() => {
console.log('Promise returned to indicate the begin config success.');
})
......@@ -1226,7 +1228,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses an
**Example**
```
```js
captureSession.commitConfig((err) => {
if (err) {
console.error('Failed to commit the configuration. ${err.message}');
......@@ -1252,7 +1254,7 @@ Commits the configuration for this **CaptureSession** instance. This API uses a
**Example**
```
```js
captureSession.commitConfig().then(() => {
console.log('Promise returned to indicate the commit config success.');
})
......@@ -1275,7 +1277,7 @@ Adds a **CameraInput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addInput(cameraInput, (err) => {
if (err) {
console.error('Failed to add the CameraInput instance. ${err.message}');
......@@ -1307,7 +1309,7 @@ Adds a **CameraInput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addInput(cameraInput).then(() => {
console.log('Promise used to indicate that the CameraInput instance is added.');
})
......@@ -1330,7 +1332,7 @@ Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API
**Example**
```
```js
captureSession.addOutput(previewOutput, (err) => {
if (err) {
console.error('Failed to add the PreviewOutput instance ${err.message}');
......@@ -1362,7 +1364,7 @@ Adds a **PreviewOutput** instance to this **CaptureSession** instance. This API
**Example**
```
```js
captureSession.addOutput(previewOutput).then(() => {
console.log('Promise used to indicate that the PreviewOutput instance is added.');
})
......@@ -1385,7 +1387,7 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to add the PhotoOutput instance ${err.message}');
......@@ -1417,7 +1419,7 @@ Adds a **PhotoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(photoOutput).then(() => {
console.log('Promise used to indicate that the PhotoOutput instance is added.');
})
......@@ -1440,7 +1442,7 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(videoOutput, (err) => {
if (err) {
console.error('Failed to add the VideoOutput instance ${err.message}');
......@@ -1472,7 +1474,7 @@ Adds a **VideoOutput** instance to this **CaptureSession** instance. This API us
**Example**
```
```js
captureSession.addOutput(videoOutput).then(() => {
console.log('Promise used to indicate that the VideoOutput instance is added.');
})
......@@ -1495,7 +1497,7 @@ Removes a **CameraInput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeInput(cameraInput, (err) => {
if (err) {
console.error('Failed to remove the CameraInput instance. ${err.message}');
......@@ -1527,7 +1529,7 @@ Removes a **CameraInput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeInput(cameraInput).then(() => {
console.log('Promise returned to indicate that the cameraInput instance is removed.');
})
......@@ -1550,7 +1552,7 @@ Removes a **PreviewOutput** instance from this **CaptureSession** instance. This
**Example**
```
```js
captureSession.removeOutput(previewOutput, (err) => {
if (err) {
console.error('Failed to remove the PreviewOutput instance. ${err.message}');
......@@ -1584,7 +1586,7 @@ Removes a **PreviewOutput** instance from this **CaptureSession** instance. This
**Example**
```
```js
captureSession.removeOutput(previewOutput).then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is removed.');
})
......@@ -1607,7 +1609,7 @@ Removes a **PhotoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(photoOutput, (err) => {
if (err) {
console.error('Failed to remove the PhotoOutput instance. ${err.message}');
......@@ -1641,7 +1643,7 @@ Removes a **PhotoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(photoOutput).then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is removed.');
})
......@@ -1664,7 +1666,7 @@ Removes a **VideoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(videoOutput, (err) => {
if (err) {
console.error('Failed to remove the VideoOutput instance. ${err.message}');
......@@ -1698,7 +1700,7 @@ Removes a **VideoOutput** instance from this **CaptureSession** instance. This A
**Example**
```
```js
captureSession.removeOutput(videoOutput).then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is removed.');
})
......@@ -1720,7 +1722,7 @@ Starts this **CaptureSession** instance. This API uses an asynchronous callback
**Example**
```
```js
captureSession.start((err) => {
if (err) {
console.error('Failed to start the session ${err.message}');
......@@ -1746,7 +1748,7 @@ Starts this **CaptureSession** instance. This API uses a promise to return the r
**Example**
```
```js
captureSession.start().then(() => {
console.log('Promise returned to indicate the session start success.');
})
......@@ -1769,7 +1771,7 @@ Stops this **CaptureSession** instance. This API uses an asynchronous callback t
**Example**
```
```js
captureSession.stop((err) => {
if (err) {
console.error('Failed to stop the session ${err.message}');
......@@ -1795,7 +1797,7 @@ Stops this **CaptureSession** instance. This API uses a promise to return the re
**Example**
```
```js
captureSession.stop().then(() => {
console.log('Promise returned to indicate the session stop success.');
})
......@@ -1817,7 +1819,7 @@ Releases this **CaptureSession** instance. This API uses an asynchronous callbac
**Example**
```
```js
captureSession.release((err) => {
if (err) {
console.error('Failed to release the CaptureSession instance ${err.message}');
......@@ -1843,7 +1845,7 @@ Releases this **CaptureSession** instance. This API uses a promise to return the
**Example**
```
```js
captureSession.release().then(() => {
console.log('Promise returned to indicate that the CaptureSession instance is released successfully.');
})
......@@ -1859,40 +1861,38 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :---------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.|
| callback | ErrorCallback<CaptureSessionError\> | Yes | Callback used to return the capture session errors. |
| Name | Type | Mandatory| Description |
| :------- | :---------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the capture session error event.|
| callback | ErrorCallback<[CaptureSessionError](#capturesessionerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
captureSession.on('error', (captureSessionError) => {
console.log('Capture session error code: ' + captureSessionError.code);
})
```
## CaptureSessionErrorCode
## CaptureSessionErrorCode
Enumerates the CaptureSession error code.
Enumerates the **CaptureSession** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN | -1 | Unknown error.|
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## CaptureSessionError
## CaptureSessionError
Capture session error object which extends **Error** interface.
Defines a **CaptureSession** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [CaptureSessionErrorCode](#capturesessionerrorcode) | Used to get error code in CaptureSession on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------------- | -------------------------- |
| code | [CaptureSessionError](#capturesessionerror) | **CaptureSession** error code.|
## camera.createPreviewOutput
......@@ -1911,7 +1911,7 @@ Creates a **PreviewOutput** instance. This API uses an asynchronous callback to
**Example**
```
```js
camera.createPreviewOutput(("surfaceId"), (err, previewOutput) => {
if (err) {
console.error('Failed to create the PreviewOutput instance. ${err.message}');
......@@ -1943,7 +1943,7 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the inst
**Example**
```
```js
camera.createPreviewOutput("surfaceId").then((previewOutput) => {
console.log('Promise returned with the PreviewOutput instance');
})
......@@ -1969,7 +1969,7 @@ Releases this **PreviewOutput** instance. This API uses an asynchronous callback
**Example**
```
```js
previewOutput.release((err) => {
if (err) {
console.error('Failed to release the PreviewOutput instance ${err.message}');
......@@ -1996,7 +1996,7 @@ Releases this **PreviewOutput** instance. This API uses a promise to return the
**Example**
```
```js
previewOutput.release().then(() => {
console.log('Promise returned to indicate that the PreviewOutput instance is released successfully.');
})
......@@ -2019,7 +2019,7 @@ Listens for preview frame start events. This API uses an asynchronous callback t
**Example**
```
```js
previewOutput.on('frameStart', () => {
console.log('Preview frame started');
})
......@@ -2042,7 +2042,7 @@ Listens for preview frame end events. This API uses an asynchronous callback to
**Example**
```
```js
previewOutput.on('frameEnd', () => {
console.log('Preview frame ended');
})
......@@ -2058,14 +2058,14 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :--------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.|
| callback | ErrorCallback<PreviewOutputError\> | Yes | Callback used to return the preview output errors. |
| Name | Type | Mandatory| Description |
| :------- | :----------------------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the preview output error event.|
| callback | ErrorCallback<[PreviewOutputErrorCode](#previewoutputerrorcode)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
previewOutput.on('error', (previewOutputError) => {
console.log('Preview output error code: ' + previewOutputError.code);
})
......@@ -2073,25 +2073,23 @@ previewOutput.on('error', (previewOutputError) => {
## PreviewOutputErrorCode
Enumerates the PreviewOutput error code.
Enumerates the **PreviewOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN | -1 | Unknown error.|
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## PreviewOutputError
## PreviewOutputError
Preview output error object which extends **Error** interface.
Defines a **PreviewOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | Used to get error code in PreviewOutput on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------------------- | ---------------------- |
| code | [PreviewOutputErrorCode](#previewoutputerrorcode) | **PreviewOutput** error code.|
## camera.createPhotoOutput
......@@ -2110,7 +2108,7 @@ Creates a **PhotoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
```js
camera.createPhotoOutput(("surfaceId"), (err, photoOutput) => {
if (err) {
console.error('Failed to create the PhotoOutput instance. ${err.message}');
......@@ -2142,7 +2140,7 @@ Creates a **PhotoOutput** instance. This API uses a promise to return the instan
**Example**
```
```js
camera.createPhotoOutput("surfaceId").then((photoOutput) => {
console.log('Promise returned with PhotoOutput instance');
})
......@@ -2153,14 +2151,12 @@ Enumerates the image rotation angles.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ------------ | ------ | --------------- |
| ROTATION_0 | 0 | The image rotates 0 degrees. |
| ROTATION_90 | 90 | The image rotates 90 degrees. |
| ROTATION_180 | 180 | The image rotates 180 degrees.|
| ROTATION_270 | 270 | The image rotates 270 degrees.|
| Name | Value | Description |
| ------------ | ---- | --------------- |
| ROTATION_0 | 0 | The image rotates 0 degrees. |
| ROTATION_90 | 90 | The image rotates 90 degrees. |
| ROTATION_180 | 180 | The image rotates 180 degrees.|
| ROTATION_270 | 270 | The image rotates 270 degrees.|
## QualityLevel
......@@ -2168,23 +2164,23 @@ Enumerates the image quality levels.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| -------------------- | ------ | -------------- |
| QUALITY_LEVEL_HIGH | 0 | High image quality. |
| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.|
| QUALITY_LEVEL_LOW | 2 | Low image quality. |
| Name | Value | Description |
| -------------------- | ---- | -------------- |
| QUALITY_LEVEL_HIGH | 0 | High image quality. |
| QUALITY_LEVEL_MEDIUM | 1 | Medium image quality.|
| QUALITY_LEVEL_LOW | 2 | Low image quality. |
## PhotoCaptureSetting
Defines the settings for image capture.
Defines the settings for photo capture.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | -------------- |
| quality | [QualityLevel](#qualitylevel) | No | Photo image quality. |
| rotation | [ImageRotation](#imagerotation) | No | Photo rotation.|
| quality | [QualityLevel](#qualitylevel) | No | Photo quality. |
| rotation | [ImageRotation](#imagerotation) | No | Rotation angle of the photo.|
## PhotoOutput
......@@ -2207,7 +2203,7 @@ Captures a photo. This API uses an asynchronous callback to return the result.
**Example**
```
```js
photoOutput.capture((err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
......@@ -2234,7 +2230,7 @@ Captures a photo with the specified capture settings. This API uses an asynchron
**Example**
```
```js
photoOutput.capture(settings, (err) => {
if (err) {
console.error('Failed to capture the photo ${err.message}');
......@@ -2267,7 +2263,7 @@ Captures a photo with the specified capture settings. This API uses a promise to
**Example**
```
```js
photoOutput.capture().then(() => {
console.log('Promise returned to indicate that photo capture request success.');
})
......@@ -2289,7 +2285,7 @@ Releases this **PhotoOutput** instance. This API uses an asynchronous callback t
**Example**
```
```js
photoOutput.release((err) => {
if (err) {
console.error('Failed to release the PhotoOutput instance ${err.message}');
......@@ -2316,7 +2312,7 @@ Releases this **PhotoOutput** instance. This API uses a promise to return the re
**Example**
```
```js
photoOutput.release().then(() => {
console.log('Promise returned to indicate that the PhotoOutput instance is released successfully.');
})
......@@ -2326,7 +2322,7 @@ photoOutput.release().then(() => {
on(type: 'captureStart', callback: AsyncCallback<number\>): void
Listens for photo capture start events. This API uses a callback to return the event information.
Listens for photo capture start events. This API uses an asynchronous callback to return the capture ID.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2339,7 +2335,7 @@ Listens for photo capture start events. This API uses a callback to return the e
**Example**
```
```js
photoOutput.on('captureStart', (err, captureId) => {
console.log('photo capture stated, captureId : ' + captureId);
})
......@@ -2349,20 +2345,20 @@ photoOutput.on('captureStart', (err, captureId) => {
on(type: 'frameShutter', callback: AsyncCallback<FrameShutterInfo\>): void
Listens for frame shutter events. This API uses a callback to return the event information.
Listens for frame shutter events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.|
| callback | AsyncCallback<FrameShutterInfo\> | Yes | Callback used to return the frame shutter information. |
| Name | Type | Mandatory| Description |
| :------- | :---------------------------------------------------- | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **frameShutter**, indicating the frame shutter event.|
| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the information. |
**Example**
```
```js
photoOutput.on('frameShutter', (frameShutterInfo) => {
console.log('photo capture end, captureId : ' + frameShutterInfo.captureId);
console.log('Timestamp for frame : ' + frameShutterInfo.timestamp);
......@@ -2373,20 +2369,20 @@ photoOutput.on('frameShutter', (frameShutterInfo) => {
on(type: 'captureEnd', callback: AsyncCallback<CaptureEndInfo\>): void
Listens for photo capture end events. This API uses a callback to return the event information.
Listens for photo capture end events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :----------------------------- | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.|
| callback | AsyncCallback<CaptureEndInfo\> | Yes | Callback used to return the photo capture end information. |
| Name | Type | Mandatory| Description |
| :------- | :------------------------------------------------ | :--- | :--------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **captureEnd**, indicating the photo capture end event.|
| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the information. |
**Example**
```
```js
photoOutput.on('captureEnd', (captureEndInfo) => {
console.log('photo capture end, captureId : ' + captureEndInfo.captureId);
console.log('frameCount : ' + captureEndInfo.frameCount);
......@@ -2403,62 +2399,60 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.|
| callback | ErrorCallback<PhotoOutputError\> | Yes | Callback used to return the photo output errors. |
| Name | Type | Mandatory| Description |
| :------- | :---------------------------------------------------- | :--- | :---------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the photo output error event.|
| callback | ErrorCallback<[PhotoOutputError](#photooutputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
photoOutput.on('error', (photoOutputError) => {
console.log('Photo output error code: ' + photoOutputError.code);
})
```
### FrameShutterInfo
## FrameShutterInfo
Frame shutter callback info which provides **captureId** & **timestamp** parameteres & indicates the frame shutter event.
Defines the frame shutter information.
**Parameteres**
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId | number | Yes | Capture id.|
| timestamp | number | Yes | Timestamp for frame.
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ----------------------------- |
| captureId | number | Yes | ID of this capture action.|
| timestamp | number | Yes | Timestamp when the frame shutter event is triggered. |
### CaptureEndInfo
## CaptureEndInfo
Capture end info which provides **captureId** & **frameCount** parameteres & indicates the photo capture end event.
Defines the capture end information.
**Parameteres**
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Type | Mandatory| Description |
| :------- | :------------------------------- | :--- | :---------------------------------------- |
| captureId | number | Yes | Capture id.|
| frameCount | number | Yes | Frame count.
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ----------------------------- |
| captureId | number | Yes | ID of this capture action.|
| frameCount | number | Yes | Number of frames captured. |
## PhotoOutputErrorCode
Enumerates the PhotoOutput error code.
Enumerates the **PhotoOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN | -1 | Unknown error.|
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## PhotoOutputError
## PhotoOutputError
Photo output error object which extends **Error** interface.
Defines a **PhotoOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [PhotoOutputErrorCode](#photooutputerrorcode) | Used to get error code in PhotoOutput on('error') callback.|
| Name| Type | Description |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **PhotoOutput** error code.|
## camera.createVideoOutput
......@@ -2477,7 +2471,7 @@ Creates a **VideoOutput** instance. This API uses an asynchronous callback to re
**Example**
```
```js
camera.createVideoOutput(("surfaceId"), (err, videoOutput) => {
if (err) {
console.error('Failed to create the VideoOutput instance. ${err.message}');
......@@ -2509,7 +2503,7 @@ Creates a **VideoOutput** instance. This API uses a promise to return the instan
**Example**
```
```js
camera.createVideoOutput("surfaceId"
).then((videoOutput) => {
console.log('Promise returned with the VideoOutput instance');
......@@ -2536,7 +2530,7 @@ Starts the video output. This API uses an asynchronous callback to return the re
**Example**
```
```js
videoOutput.start((err) => {
if (err) {
console.error('Failed to start the video output ${err.message}');
......@@ -2563,7 +2557,7 @@ Starts the video output. This API uses a promise to return the result.
**Example**
```
```js
videoOutput.start().then(() => {
console.log('Promise returned to indicate that start method execution success.');
})
......@@ -2585,7 +2579,7 @@ Stops the video output. This API uses an asynchronous callback to return the res
**Example**
```
```js
videoOutput.stop((err) => {
if (err) {
console.error('Failed to stop the video output ${err.message}');
......@@ -2611,7 +2605,7 @@ Stops the video output. This API uses a promise to return the result.
**Example**
```
```js
videoOutput.start().then(() => {
console.log('Promise returned to indicate that stop method execution success.');
})
......@@ -2633,7 +2627,7 @@ Releases this **VideoOutput** instance. This API uses an asynchronous callback t
**Example**
```
```js
videoOutput.release((err) => {
if (err) {
console.error('Failed to release the VideoOutput instance ${err.message}');
......@@ -2660,7 +2654,7 @@ Releases this **VideoOutput** instance. This API uses a promise to return the re
**Example**
```
```js
videoOutput.release().then(() => {
console.log('Promise returned to indicate that the VideoOutput instance is released successfully.');
})
......@@ -2670,7 +2664,7 @@ videoOutput.release().then(() => {
on(type: 'frameStart', callback: AsyncCallback<void\>): void
Listens for video frame start events. This API uses a callback to return the event information.
Listens for video frame start events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2683,7 +2677,7 @@ Listens for video frame start events. This API uses a callback to return the eve
**Example**
```
```js
videoOutput.on('frameStart', () => {
console.log('Video frame started');
})
......@@ -2693,7 +2687,7 @@ videoOutput.on('frameStart', () => {
on(type: 'frameEnd', callback: AsyncCallback<void\>): void
Listens for video frame end events. This API uses a callback to return the event information.
Listens for video frame end events. This API uses an asynchronous callback to return the event information.
**System capability**: SystemCapability.Multimedia.Camera.Core
......@@ -2706,7 +2700,7 @@ Listens for video frame end events. This API uses a callback to return the event
**Example**
```
```js
videoOutput.on('frameEnd', () => {
console.log('Video frame ended');
})
......@@ -2722,14 +2716,14 @@ Listens for **VideoOutput** errors. This API uses a callback to return the error
**Parameters**
| Name | Type | Mandatory| Description |
| :------- | :-------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.|
| callback | Callback<VideoOutputError\> | Yes | Callback used to return the video output errors. |
| Name | Type | Mandatory| Description |
| :------- | :----------------------------------------------- | :--- | :-------------------------------------------- |
| type | string | Yes | Type of event to listen for. The value is fixed at **error**, indicating the video output error event.|
| callback | Callback<[VideoOutputError](#videooutputerror)\> | Yes | Callback used to return the error information. |
**Example**
```
```js
videoOutput.on('error', (VideoOutputError) => {
console.log('Video output error code: ' + VideoOutputError.code);
})
......@@ -2737,22 +2731,20 @@ videoOutput.on('error', (VideoOutputError) => {
## VideoOutputErrorCode
Enumerates the VideoOutput error code.
Enumerates the **VideoOutput** error codes.
**System capability**: SystemCapability.Multimedia.Camera.Core
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| ERROR_UNKNOWN | -1 | Unknown error.|
| Name | Value | Description |
| ------------- | ---- | ---------- |
| ERROR_UNKNOWN | -1 | Unknown error.|
## VideoOutputError
## VideoOutputError
Photo output error object which extends **Error** interface.
Defines a **VideoOutput** error object.
**System capability**: SystemCapability.Multimedia.Camera.Core
**Parameters**
| Name | Default Value| Description |
| ---------------------- | ------ | ------------ |
| code | [VideoOutputErrorCode](#videooutputerrorcode) | Used to get error code in VideoOutput on('error') callback.|
\ No newline at end of file
| Name| Type | Description |
| ---- | ------------------------------------- | ----------------------- |
| code | [PhotoOutputError](#photooutputerror) | **VideoOutput** error code.|
......@@ -34,6 +34,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then((pixelmap) => {
......@@ -60,6 +61,7 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => {
})
......@@ -100,10 +102,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example**
```js
pixelmap.readPixelsToBuffer(ReadBuffer).then(() => {
console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
const readBuffer = new ArrayBuffer(400);
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
}).catch(error => {
console.log('readPixelsToBuffer failed.'); // Called if no condition is met.
('Failed to read image pixel data.'); // Called if no condition is met.
})
```
......@@ -125,11 +128,12 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
**Example**
```js
pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => {
const readBuffer = new ArrayBuffer(400);
pixelmap.readPixelsToBuffer(readBuffer, (err, res) => {
if(err) {
console.log('readPixelsToBuffer failed.'); // Called if the condition is met.
console.log('Failed to read image pixel data.'); // Called if no condition is met.
} else {
console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met.
console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
}
})
```
......@@ -157,10 +161,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat
**Example**
```js
pixelmap.readPixels(Area).then((data) => {
console.log('readPixels succeeded.'); // Called if the condition is met.
const area = new ArrayBuffer(400);
pixelmap.readPixels(area).then(() => {
console.log('Succeeded in reading the image data in the area.'); // Called if the condition is met.
}).catch(error => {
console.log('readPixels failed.'); // Called if no condition is met.
console.log('Failed to read the image data in the area.'); // Called if no condition is met.
})
```
......@@ -182,6 +187,8 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to
**Example**
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
if(pixelmap == undefined){
......@@ -222,6 +229,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
......@@ -233,7 +241,7 @@ image.createPixelMap(color, opts)
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
let bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
......@@ -269,13 +277,18 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t
**Example**
```js
pixelmap.writePixels(Area, () => {
const readArea = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
}
const area = new ArrayBuffer(400);
pixelmap.writePixels(area, (error) => {
if (error!=undefined) {
console.info('Failed to write pixelmap into the specified area.');
} else {
const readArea = {
pixels: new ArrayBuffer(20),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
}
}
})
```
......@@ -302,7 +315,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example**
```js
PixelMap.writeBufferToPixels(color).then(() => {
const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
pixelMap.writeBufferToPixels(color).then(() => {
console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => {
console.error("Failed to write data from a buffer to a PixelMap.");
......@@ -327,7 +343,10 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj
**Example**
```js
PixelMap.writeBufferToPixels(color, function(err) {
const color = new ArrayBuffer(96);\
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
pixelMap.writeBufferToPixels(color, function(err) {
if (err) {
console.error("Failed to write data from a buffer to a PixelMap.");
return;
......@@ -354,7 +373,8 @@ Obtains pixel map information of this image. This API uses a promise to return t
**Example**
```js
PixelMap.getImageInfo().then(function(info) {
const pixelMap = new ArrayBuffer(400);
pixelMap.getImageInfo().then(function(info) {
console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => {
console.error("Failed to obtain the image pixel map information.");
......@@ -379,9 +399,7 @@ Obtains pixel map information of this image. This API uses an asynchronous callb
```js
pixelmap.getImageInfo((imageInfo) => {
console.log("getImageInfo succeeded.");
}).catch((err) => {
console.error("getImageInfo failed.");
console.log("Succeeded in obtaining the image pixel map information..");
})
```
......@@ -402,7 +420,10 @@ Obtains the number of bytes per line of the image pixel map.
**Example**
```js
image.createPixelMap(clolr, opts, (err,pixelmap) => {
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) => {
let rowCount = pixelmap.getBytesNumberPerRow();
})
```
......@@ -444,11 +465,14 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
**Example**
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => {
console.log('release succeeded.');
console.log('Succeeded in releasing pixelmap object.');
}).catch(error => {
console.log('release failed.');
console.log('Failed to release pixelmap object.');
})
})
```
......@@ -470,11 +494,14 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret
**Example**
```js
const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => {
console.log('release succeeded.');
console.log('Succeeded in releasing pixelmap object.');
}).catch(error => {
console.log('release failed.');
console.log('Failed to release pixelmap object.');
})
})
```
......@@ -589,9 +616,7 @@ Obtains information about this image. This API uses an asynchronous callback to
```js
imageSourceApi.getImageInfo(imageInfo => {
console.log('getImageInfo succeeded.');
}).catch(error => {
console.log('getImageInfo failed.');
console.log('Succeeded in obtaining the image information.');
})
```
......@@ -620,9 +645,9 @@ Obtains information about an image with the specified index. This API uses a pro
```js
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
console.log('getImageInfo succeeded.');
console.log('Succeeded in obtaining the image information.');
}).catch(error => {
console.log('getImageInfo failed.');
console.log('Failed to obtain the image information.');
})
```
......@@ -652,9 +677,7 @@ Obtains the value of a property with the specified index in this image. This API
```js
imageSourceApi.getImageProperty("BitsPerSample")
.then(data => {
console.log('getImageProperty succeeded.');
}).catch(error => {
console.log('getImageProperty failed.');
console.log('Succeeded in getting the value of the specified attribute key of the image.');
})
```
......@@ -678,9 +701,9 @@ Obtains the value of a property with the specified index in this image. This API
```js
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
if(error) {
console.log('getImageProperty failed.');
console.log('Failed to get the value of the specified attribute key of the image.');
} else {
console.log('getImageProperty succeeded.');
console.log('Succeeded in getting the value of the specified attribute key of the image.');
}
})
```
......@@ -704,11 +727,12 @@ Obtains the value of a property in this image. This API uses an asynchronous cal
**Example**
```js
imageSourceApi.getImageProperty("BitsPerSample",Property,(error,data) => {
const property = new ArrayBuffer(400);
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {
if(error) {
console.log('getImageProperty failed.');
console.log('Failed to get the value of the specified attribute key of the image.');
} else {
console.log('getImageProperty succeeded.');
console.log('Succeeded in getting the value of the specified attribute key of the image.');
}
})
```
......@@ -737,9 +761,9 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
```js
imageSourceApi.createPixelMap().then(pixelmap => {
console.log('createPixelMap succeeded.');
console.log('Succeeded in creating pixelmap object through image decoding parameters.');
}).catch(error => {
console.log('createPixelMap failed.');
console.log('Failed to create pixelmap object through image decoding parameters.');
})
```
......@@ -761,9 +785,9 @@ Creates a **PixelMap** object based on the default parameters. This API uses an
```js
imageSourceApi.createPixelMap(pixelmap => {
console.log('createPixelMap succeeded.');
console.log('Succeeded in creating pixelmap object.');
}).catch(error => {
console.log('createPixelMap failed.');
console.log('Failed to create pixelmap object.');
})
```
......@@ -785,11 +809,10 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Example**
```js
const decodingOptions = new ArrayBuffer(400);
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.log('createPixelMap succeeded.');
}).catch(error => {
console.log('createPixelMap failed.');
})
console.log('Succeeded in creating pixelmap object.');
})
```
### release
......@@ -811,8 +834,6 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t
```js
imageSourceApi.release(() => {
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
})
```
......@@ -834,9 +855,9 @@ Releases this **ImageSource** instance. This API uses a promise to return the re
```js
imageSourceApi.release().then(()=>{
console.log('release succeeded.');
console.log('Succeeded in releasing the image source instance.');
}).catch(error => {
console.log('release failed.');
console.log('Failed to release the image source instance.');
})
```
......@@ -891,8 +912,9 @@ Packs an image. This API uses an asynchronous callback to return the result.
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 };
imagePackerApi.packing(ImageSourceApi, packOpts, data => {})
let packOpts = { format:"image/jpeg", quality:98 };
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
```
### packing
......@@ -919,8 +941,9 @@ Packs an image. This API uses a promise to return the result.
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(ImageSourceApi, packOpts)
let packOpts = { format:"image/jpeg", quality:98 }
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
console.log('packing succeeded.');
}).catch(error => {
......@@ -947,11 +970,12 @@ Packs an image. This API uses an asynchronous callback to return the result.
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(PixelMapApi, packOpts, data => {
console.log('packing succeeded.');
let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts, data => {
console.log('Succeeded in packing the image.');
}).catch(error => {
console.log('packing failed.');
console.log('Failed to pack the image.');
})
```
......@@ -979,12 +1003,13 @@ Packs an image. This API uses a promise to return the result.
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(PixelMapApi, packOpts)
let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts)
.then( data => {
console.log('packing succeeded.');
console.log('Succeeded in packing the image.');
}).catch(error => {
console.log('packing failed.');
console.log('Failed to pack the image..');
})
```
......@@ -1006,9 +1031,7 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t
```js
imagePackerApi.release(()=>{
console.log('release succeeded.');
}).catch(error => {
console.log('release failed.');
console.log('Succeeded in releasing image packaging.');
})
```
......@@ -1030,9 +1053,9 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re
```js
imagePackerApi.release().then(()=>{
console.log('release succeeded.');
console.log('Succeeded in releasing image packaging.');
}).catch((error)=>{
console.log('release failed.');
console.log('Failed to release image packaging.');
})
```
......@@ -1098,7 +1121,7 @@ Obtains a surface ID for the camera or other components. This API uses an asynch
**Example**
```js
receiver.getReceivingSurfaceId((err, id) => {
receiver.getReceivingSurfaceId((err, id) => {
if(err) {
console.log('getReceivingSurfaceId failed.');
} else {
......@@ -1513,7 +1536,7 @@ Defines image decoding options.
| desiredSize | [Size](#size) | Yes | Yes | Expected output size. |
| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. |
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.|
| index | number | Yes | Yes | Index of the image to decode. |
| index | number | Yes | Yes | Index of the image to decode. |
## Region<sup>7+</sup>
......@@ -1536,7 +1559,7 @@ Defines the option for image packing.
| Name | Type | Readable| Writable| Description |
| ------- | ------ | ---- | ---- | -------------- |
| format | string | Yes | Yes | Format of the packed image. |
| quality | number | Yes | Yes | Quality of the packed image.|
| quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.|
## GetImagePropertyOptions<sup>7+</sup>
......
......@@ -886,11 +886,7 @@ Subscribes to only one data change of the proximity sensor.
**Example**
```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) {
console.info('Distance: ' + data.distance);
}
);
......@@ -1350,8 +1346,6 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
Unsubscribes from sensor data changes.
**Required permission**: ohos.permission.READ_HEALTH_DATA (a system permission)
**System capability**: SystemCapability.Sensors.Sensor
**Parameters**
......@@ -1404,8 +1398,6 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
Unsubscribes from sensor data changes.
**Required permissions**: ohos.permission.ACCELEROMETER (a system permission)
**System capability**: SystemCapability.Sensors.Sensor
**Parameters**
......@@ -1487,6 +1479,8 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
Unsubscribes from sensor data changes.
**Required permissions**: ohos.permission.ACTIVITY_MOTION
**System capability**: SystemCapability.Sensors.Sensor
**Parameters**
......@@ -1739,7 +1733,7 @@ Obtains the geomagnetic field of a geographic location. This API uses a promise
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field. |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | Promise used to return the geomagnetic field.|
**Example**
```js
......@@ -1899,7 +1893,6 @@ Obtains the angle change between two rotation matrices. This API uses a callback
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
......@@ -1967,7 +1960,6 @@ Converts a rotation vector into a rotation matrix. This API uses a callback to r
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
......@@ -2034,7 +2026,6 @@ Converts a rotation vector into a quaternion. This API uses a callback to return
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i]);
}
......@@ -2169,7 +2160,6 @@ Creates a rotation matrix based on the gravity vector and geomagnetic vector. Th
err.message);
return;
}
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) {
console.info("data[" + i + "]: " + data[i])
}
......
......@@ -12,17 +12,17 @@ WebGL helps you process graphics at the frontend, for example, drawing color gra
| API| Description|
| -------- | -------- |
| canvas.getContext | Obtains the canvas context.|
| webgl.createBuffer():&nbsp;WebGLBuffer&nbsp;\|&nbsp;null | Creates and initializes a WebGL buffer.|
| webgl.bindBuffer(target:&nbsp;GLenum,&nbsp;buffer:&nbsp;WebGLBuffer&nbsp;\|&nbsp;null):&nbsp;void | Binds the WebGL buffer to the target.|
| webgl.bufferData(target:&nbsp;GLenum,&nbsp;srcData:&nbsp;ArrayBufferView,&nbsp;usage:&nbsp;GLenum,&nbsp;srcOffset:&nbsp;GLuint,&nbsp;length?:&nbsp;GLuint):&nbsp;void | Creates and initializes the WebGL buffer object's data store.|
| webgl.getAttribLocation(program:&nbsp;WebGLProgram,&nbsp;name:&nbsp;string):&nbsp;GLint | Obtains the address of the **attribute** variable in the shader from the given WebGLProgram.|
| webgl.vertexAttribPointer(index:&nbsp;GLuint,&nbsp;size:&nbsp;GLint,&nbsp;type:&nbsp;GLenum,&nbsp;normalized:&nbsp;GLboolean,&nbsp;stride:&nbsp;GLsizei,&nbsp;offset:&nbsp;GLintptr):&nbsp;void | Assigns a **Buffer** object to a variable.|
| webgl.enableVertexAttribArray(index:&nbsp;GLuint):&nbsp;void | Connects a variable to the **Buffer** object allocated to it.|
| webgl.clearColor(red:&nbsp;GLclampf,&nbsp;green:&nbsp;GLclampf,&nbsp;blue:&nbsp;GLclampf,&nbsp;alpha:&nbsp;GLclampf):&nbsp;void | Clears the specified color on the **\<canvas>** component.|
| webgl.clear(mask:&nbsp;GLbitfield):&nbsp;void | Clears the **\<canvas>** component.|
| webgl.drawArrays(mode:&nbsp;GLenum,&nbsp;first:&nbsp;GLint,&nbsp;count:&nbsp;GLsizei):&nbsp;void | Draws data.|
| webgl.flush():&nbsp;void | Flushes data to the GPU and clears the buffer.|
| webgl.createProgram():&nbsp;WebGLProgram&nbsp;\|&nbsp;null | Creates a **WebGLProgram** object.|
| webgl.createBuffer(): WebGLBuffer \| null | Creates and initializes a WebGL buffer.|
| webgl.bindBuffer(target: GLenum, buffer: WebGLBuffer \| null): void | Binds the WebGL buffer to the target.|
| webgl.bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint): void | Creates and initializes the WebGL buffer object's data store.|
| webgl.getAttribLocation(program: WebGLProgram, name: string): GLint | Obtains the address of the **attribute** variable in the shader from the given WebGLProgram.|
| webgl.vertexAttribPointer(index GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr): void | Assigns a **Buffer** object to a variable.|
| webgl.enableVertexAttribArray(index: GLuint): void | Connects a variable to the **Buffer** object allocated to it.|
| webgl.clearColor(red: GLclampf, green:GLclampf, blue: GLclampf, alpha: GLclampf): void | Clears the specified color on the **\<canvas>** component.|
| webgl.clear(mask: GLbitfield): void | Clears the **\<canvas>** component.|
| webgl.drawArrays(mode: GLenum, first:;GLint, count: GLsizei): void | Draws data.|
| webgl.flush(): void | Flushes data to the GPU and clears the buffer.|
| webgl.createProgram(): WebGLProgram \| null | Creates a **WebGLProgram** object.|
## How to Develop
......@@ -699,3 +699,9 @@ To use WebGL to draw a color triangle (GPU drawing), perform the following steps
**Figure 2** Effect of clicking the button to draw a color triangle
![en-us_image_0000001192429306](figures/en-us_image_0000001192429306.gif)
## Samples
The following sample is provided to help you better understand how to develop WebGL:
- [`JsWbgGL`: WebGL (JS, API version 8)](https://gitee.com/openharmony/app_samples/tree/master/Graphics/JsWebGL)
......@@ -52,7 +52,7 @@ The table below lists the length of `sizeof` and `print` in ILP32 and LP64 to sh
| unsigned long int | 4 | %lu | **8** | %lu | Differences exist.|
| long long | 8 | %lld | 8 | %lld | |
| unsigned long long | 8 | %llu | 8 | %llu | |
| type * | 4 | %p | **8** | %p | Differences exist.|
| type \* | 4 | %p | **8** | %p | Differences exist.|
| pid_t | 4 | %d | 4 | %d | |
| socklen_t | 4 | %u | 4 | %u | |
| off_t | 4 | %zd | **8** | %zd | Differences exist.|
......@@ -121,7 +121,7 @@ Although uint64\_t has a fixed length, **sizeof(Foo)** is different due to align
| double | 8 | 8 | %lf | Used for double-precision floating point numbers.|
| bool | 1 | 1 | %d | Used for Boolean.|
| uintptr_t | **4** | **8** | %zu | Used for pointer storage. Different lengths are defined for 32- and 64-bit OSs.|
| type * | **4** | **8** | %p | Variable-length type. It is equivalent to uintptr_t, which is recommended for type conversion.|
| type \* | **4** | **8** | %p | Variable-length type. It is equivalent to uintptr_t, which is recommended for type conversion.|
| nullptr_t | **4** | **8** | %p | Used for pointer initialization.|
| pid_t | 4 | 4 | %d | Built-in for the Linux kernel. It has a fixed length.|
| socklen_t | 4 | 4 | %u | Built-in for the Linux kernel. It has a fixed length.|
......@@ -353,13 +353,13 @@ p = (int32_t *)malloc(sizeof(p) * ELEMENTS_NUMBER);
[Example]
```c
#pragma pack(push) # Save the current alignment mode.
#pragma pack(1) # Set the alignment mode to 1-byte alignment.
#pragma pack(push) // Save the current alignment mode.
#pragma pack(1) // Set the alignment mode to 1-byte alignment.
struct test
{
......
};
#pragma pack(pop) # Restore the previous alignment mode.
#pragma pack(pop) // Restore the previous alignment mode.
```
#### [Rule] Uniform the message structures related to multi-device communication. For compatibility purposes, 1-byte alignment is preferred. Do not use 8-byte alignment or 64-bit data types to avoid errors during communication with a 32-bit OS.
......@@ -492,9 +492,9 @@ printf("t2 = %lu\n", t2);
t1 is a signed negative 32-bit number, which must be extended with signs. The most significant bits of the negative number are all fs, and the value after extension is 0xffffffffffffffff. t2 is an unsigned 64-bit number, the value of which is a large positive number.
#### [Rule] When a pointer is used as the base address and the offset is calculated by byte, the pointer must be forcibly converted to a single-byte pointer such as uintptr_t or uint8_t *.
#### [Rule] When a pointer is used as the base address and the offset is calculated by byte, the pointer must be forcibly converted to a single-byte pointer such as uintptr_t or uint8_t \*.
[Description] If the pointer is converted to an integer of the uint32_t type, the pointer may be truncated. This will not occur if the pointer is converted to uintptr_t. The pointer can also be converted to a single-byte pointer such as uint8_t * and char *. In this case, the offset is considered as bytes. A one-byte offset will be carried out for the void * type. To clarify the type, you are advised to use the type that is more specific.
[Description] If the pointer is converted to an integer of the uint32_t type, the pointer may be truncated. This will not occur if the pointer is converted to uintptr_t. The pointer can also be converted to a single-byte pointer such as uint8_t \* and char \*. In this case, the offset is considered as bytes. A one-byte offset will be carried out for the void \* type. To clarify the type, you are advised to use the type that is more specific.
[Example]
......@@ -503,13 +503,13 @@ t1 is a signed negative 32-bit number, which must be extended with signs. The mo
void *pPkt = (void *)((uint32_t)MSG_GET_DATA_ADDR(msgAddr) + OFFSET);
// Correct
void *pPkt = (void *)((uintptr_t)MSG_GET_DATA_ADDR(msgAddr) + OFFSET);// C
void *pPkt = (void *)((uintptr_t)MSG_GET_DATA_ADDR(msgAddr) + OFFSET); // C
void *pPkt = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(MSG_GET_DATA_ADDR(msgAddr)) + OFFSET); // C++
```
#### [Rule] Mutual assignment is forbidden between pointers and uint32_t, including function parameter passing.
[Description] If the variable to be defined is a length-variable pointer, use void *. If the variable to be defined is a pointer or an integer, use uintptr_t.
[Description] If the variable to be defined is a length-variable pointer, use void \*. If the variable to be defined is a pointer or an integer, use uintptr_t.
[Example] Conversion between pointers and integers
......
......@@ -3,7 +3,7 @@
## 场景介绍
使用WebSocket建立服务器与客户端的双向连接,需要先通过createWebSocket方法创建WebSocket对象,然后通过connect方法连接到服务器。当连接成功后,客户端会收到open事件的回调,之后客户端就可以通过send方法与服务器进行通信。当服务器发信息给客户端时,客户端会收到message事件的回调。当客户端不要此连接时,可以通过调用close方法主动断开连接,之后客户端会收到close事件的回调。
使用WebSocket建立服务器与客户端的双向连接,需要先通过createWebSocket()方法创建WebSocket对象,然后通过connect()方法连接到服务器。当连接成功后,客户端会收到open事件的回调,之后客户端就可以通过send()方法与服务器进行通信。当服务器发信息给客户端时,客户端会收到message事件的回调。当客户端不要此连接时,可以通过调用close()方法主动断开连接,之后客户端会收到close事件的回调。
若在上述任一过程中发生错误,客户端会收到error事件的回调。
......@@ -18,23 +18,23 @@ WebSocket连接功能主要由webSocket模块提供。使用该功能需要申
| connect() | 根据URL地址,建立一个WebSocket连接。 |
| send() | 通过WebSocket连接发送数据。 |
| close() | 关闭WebSocket连接。 |
| on(type:&nbsp;'open') | 订阅WebSocket的打开事件。 |
| off(type:&nbsp;'open') | 取消订阅WebSocket的打开事件。 |
| on(type:&nbsp;'message') | 订阅WebSocket的接收到服务器消息事件。 |
| off(type:&nbsp;'message') | 取消订阅WebSocket的接收到服务器消息事件。 |
| on(type:&nbsp;'close') | 订阅WebSocket的关闭事件。 |
| off(type:&nbsp;'close') | 取消订阅WebSocket的关闭事件 |
| on(type:&nbsp;'error') | 订阅WebSocket的Error事件。 |
| off(type:&nbsp;'error') | 取消订阅WebSocket的Error事件。 |
| on(type: 'open') | 订阅WebSocket的打开事件。 |
| off(type: 'open') | 取消订阅WebSocket的打开事件。 |
| on(type: 'message') | 订阅WebSocket的接收到服务器消息事件。 |
| off(type: 'message') | 取消订阅WebSocket的接收到服务器消息事件。 |
| on(type: 'close') | 订阅WebSocket的关闭事件。 |
| off(type: 'close') | 取消订阅WebSocket的关闭事件 |
| on(type: 'error') | 订阅WebSocket的Error事件。 |
| off(type: 'error') | 取消订阅WebSocket的Error事件。 |
## 开发步骤
1. import需要的webSocket模块。
1. 导入需要的webSocket模块。
2. 创建一个WebSocket连接,返回一个WebSocket对象。
3. (可选)订阅WebSocket的打开、消息、关闭、Error事件。
3. (可选)订阅WebSocket的打开、消息接收、关闭、Error事件。
4. 根据URL地址,发起WebSocket连接。
......@@ -50,9 +50,9 @@ WebSocket连接功能主要由webSocket模块提供。使用该功能需要申
// 当收到on('open')事件时,可以通过send()方法与服务器进行通信
ws.send("Hello, server!", (err, value) => {
if (!err) {
console.log("send success");
console.log("Message sent successfully");
} else {
console.log("send fail, err:" + JSON.stringify(err));
console.log("Failed to send the message. Err:" + JSON.stringify(err));
}
});
});
......@@ -62,9 +62,9 @@ WebSocket连接功能主要由webSocket模块提供。使用该功能需要申
if (value === 'bye') {
ws.close((err, value) => {
if (!err) {
console.log("close success");
console.log("Connection closed successfully");
} else {
console.log("close fail, err is " + JSON.stringify(err));
console.log("Failed to close the connection. Err: " + JSON.stringify(err));
}
});
}
......@@ -77,9 +77,9 @@ WebSocket连接功能主要由webSocket模块提供。使用该功能需要申
});
ws.connect(defaultIpAddress, (err, value) => {
if (!err) {
console.log("connect success");
console.log("Connected successfully");
} else {
console.log("connect fail, err:" + JSON.stringify(err));
console.log("Connection failed. Err:" + JSON.stringify(err));
}
});
```
......@@ -33,12 +33,12 @@
```
mkdir server_sample // 建立示例服务器server_sample目录
touch server_sample/BUILD.gn // 创建BUILD.gn编译文件
mkdir server_sample/include // 建立示例服务器头文件include目录
touch server_process.h // 创建server_process.h头文件
touch server_sample/BUILD.gn // 创建BUILD.gn编译文件
mkdir server_sample/include // 建立示例服务器头文件include目录
touch server_process.h // 创建server_process.h头文件
mkdir server_sample/src // 建立示例服务器c/c++文件src目录
touch server_sample/src/server_process.c // 创建server_process.c文件
touch server_sample/src/main.cpp // 创建main.cpp文件
touch server_sample/src/server_process.c // 创建server_process.c文件
touch server_sample/src/main.cpp // 创建main.cpp文件
```
4. 编写编译文件BUILD.gn
......
# 动画
本模块提供组件动画效果,包括定义动画、启动动画和以相反的顺序播放动画等。
> **说明:**
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......@@ -21,14 +23,14 @@ createAnimator(options: AnimatorOptions): AnimatorResult
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。|
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。|
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| [AnimatorResult](#animatorresult) | Animator结果接口。 |
| 类型 | 说明 |
| -------- | -------- |
| [AnimatorResult](#animatorresult) | Animator结果接口。 |
**示例:**
......@@ -92,9 +94,9 @@ update(options: AnimatorOptions): void
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。|
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [AnimatorOptions](#animatoroptions) | 是 | 定义动画选项。|
**示例:**
```
......@@ -175,9 +177,9 @@ onframe: (progress: number) => void
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| progress | number | 是 | 动画的当前进度。|
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| progress | number | 是 | 动画的当前进度。|
**示例:**
```
......
# 性能打点
本模块提供了追踪进程轨迹。
> **说明:**
> - 从API Version 8开始,该接口不再维护,推荐使用新接口[`@ohos.hiTraceMeter`](js-apis-hitracemeter.md)。
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# 有源标签
本模块提供有源标签的使用,包括初始化有源标签芯片、读取有源标签内容、写入内容到有源标签等。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# 联系人
本模块提供联系人管理能力,包括添加联系人、删除联系人、更新联系人等
>**说明:**
>
>本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# ContinuationExtraParams
本模块提供流转管理入口中互联面板所需的过滤参数。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......@@ -15,7 +17,7 @@ import continuationManager from "@ohos.continuation.continuationManager"
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.DistributedAbilityManager
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| deviceType | Array\<string> | 是 | 是 | 表示设备类型。|
| targetBundle | string | 是 | 是 | 表示目标包名。 |
......
# xml转换JavaScript
本模块提供转换xml文本为JavaScript对象的选项。
> **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# 目录环境能力
该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口为系统接口,三方应用不支持调用。
该模块提供环境目录能力,获取内存存储根目录、公共文件根目录的JS接口。
## 导入模块
```js
......
文件管理
# 文件管理
该模块提供文件存储管理能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
该模块提供文件存储管理能力,包括文件基本管理、文件目录管理、文件信息统计、文件流式读写等常用功能。
## 导入模块
......@@ -41,9 +42,9 @@ stat(path: string): Promise&lt;Stat&gt;
**返回值:**
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回文件的具体信息。 |
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回文件的具体信息。 |
**示例:**
```js
......@@ -92,9 +93,9 @@ statSync(path:string): Stat
**返回值:**
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件的具体信息。 |
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件的具体信息。 |
**示例:**
```js
......@@ -117,9 +118,9 @@ opendir(path: string): Promise&lt;Dir&gt;
| path | string | 是 | 待打开文件目录的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| -------------------------- | -------- |
| Promise&lt;[Dir](#dir)&gt; | Promise对象。返回Dir对象。 |
| 类型 | 说明 |
| -------------------------- | -------- |
| Promise&lt;[Dir](#dir)&gt; | Promise对象。返回Dir对象。 |
**示例:**
```js
......@@ -171,9 +172,9 @@ opendirSync(path: string): Dir
| path | string | 是 | 待打开文件目录的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ----------- | -------- |
| [Dir](#dir) | 返回Dir对象。 |
| 类型 | 说明 |
| ----------- | -------- |
| [Dir](#dir) | 返回Dir对象。 |
**示例:**
```js
......@@ -199,9 +200,9 @@ access(path: string, mode?: number): Promise&lt;void&gt;
| mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。<br/>确认当前进程是否具有对应权限:<br/>-&nbsp;0:确认文件是否存在。<br/>-&nbsp;1:确认当前进程是否具有可执行权限。<br/>-&nbsp;2:确认当前进程是否具有写权限。<br/>-&nbsp;4:确认当前进程是否具有读权限。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -269,14 +270,14 @@ close(fd: number):Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -298,10 +299,10 @@ close(fd: number, callback:AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件之后的回调。 |
**示例:**
```js
......@@ -321,9 +322,9 @@ closeSync(fd: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待关闭文件的文件描述符。 |
**示例:**
```js
......@@ -340,9 +341,9 @@ close(): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -363,9 +364,9 @@ close(callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件流之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件流之后的回调。 |
**示例:**
```js
......@@ -384,16 +385,16 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise&lt;voi
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -414,12 +415,12 @@ copyFile(src: string | number, dest: string | number, mode: number, callback: As
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步复制文件之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步复制文件之后的回调。 |
**示例:**
```js
......@@ -438,11 +439,11 @@ copyFileSync(src: string | number, dest: string | number, mode?: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | -------------------------- | ---- | ---------------------------------------- |
| src | string&nbsp;\|&nbsp;number | 是 | 待复制文件的路径或待复制文件的描述符。 |
| dest | string&nbsp;\|&nbsp;number | 是 | 目标文件路径或目标文件描述符。 |
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。<br/>0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
**示例:**
```js
......@@ -465,9 +466,9 @@ mkdir(path:string, mode?: number): Promise&lt;void&gt;
| mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。<br/>-&nbsp;0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -538,9 +539,9 @@ open(path: string, flags?: number, mode?: number): Promise&lt;number&gt;
| mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。<br/>-&nbsp;0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ----------- |
| Promise&lt;number&gt; | Promise对象。返回打开文件的文件描述符。 |
| 类型 | 说明 |
| --------------------- | ----------- |
| Promise&lt;number&gt; | Promise对象。返回打开文件的文件描述符。 |
**示例:**
```js
......@@ -592,9 +593,9 @@ openSync(path:string, flags?:number, mode?:number): number
| mode | number | 否 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o666。<br/>-&nbsp;0o666:所有者具有读、写权限,所有用户组具有读、写权限,其余用户具有读、写权限。<br/>-&nbsp;0o640:所有者具有读、写权限,所有用户组具有读权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。<br/>创建出的文件权限受umask影响,umask随进程启动确定,其修改当前不开放。 |
**返回值:**
| 类型 | 说明 |
| ------ | ----------- |
| number | 打开文件的文件描述符。 |
| 类型 | 说明 |
| ------ | ----------- |
| number | 打开文件的文件描述符。 |
**示例:**
```js
......@@ -631,9 +632,9 @@ read(fd: number, buffer: ArrayBuffer, options?: {
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
......@@ -661,12 +662,12 @@ read(fd: number, buffer: ArrayBuffer, options: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待读取文件的文件描述符。 |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步读取数据之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待读取文件的文件描述符。 |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步读取数据之后的回调。 |
**示例:**
```js
......@@ -694,16 +695,16 @@ readSync(fd: number, buffer: ArrayBuffer, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待读取文件的文件描述符。 |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待读取文件的文件描述符。 |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------- |
| number | 实际读取的长度。 |
| 类型 | 说明 |
| ------ | -------- |
| number | 实际读取的长度。 |
**示例:**
```js
......@@ -727,9 +728,9 @@ rmdir(path: string): Promise&lt;void&gt;
| path | string | 是 | 待删除目录的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -797,9 +798,9 @@ unlink(path:string): Promise&lt;void&gt;
| path | string | 是 | 待删除文件的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -866,16 +867,16 @@ write(fd: number, buffer: ArrayBuffer | string, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
**示例:**
```js
......@@ -902,12 +903,12 @@ write(fd: number, buffer: ArrayBuffer | string, options: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 异步将数据写入完成后执行的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 异步将数据写入完成后执行的回调函数。 |
**示例:**
```js
......@@ -934,16 +935,16 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待写入文件的文件描述符。 |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------- |
| number | 实际写入的长度。 |
| 类型 | 说明 |
| ------ | -------- |
| number | 实际写入的长度。 |
**示例:**
```js
......@@ -967,9 +968,9 @@ hash(path: string, algorithm: string): Promise&lt;string&gt;
| algorithm | string | 是 | 哈希计算采用的算法。可选&nbsp;"md5"、"sha1"&nbsp;&nbsp;"sha256"。建议采用安全强度更高的&nbsp;"sha256"。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise对象。返回文件的哈希值。表示为十六进制数字串,所有字母均大写。 |
| 类型 | 说明 |
| --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise对象。返回文件的哈希值。表示为十六进制数字串,所有字母均大写。 |
**示例:**
```js
......@@ -1021,9 +1022,9 @@ chmod(path: string, mode: number):Promise&lt;void&gt;
| mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1087,14 +1088,14 @@ fstat(fd: number): Promise&lt;Stat&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回表示文件状态的具体信息。 |
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | Promise对象。返回表示文件状态的具体信息。 |
**示例:**
```js
......@@ -1115,10 +1116,10 @@ fstat(fd: number, callback: AsyncCallback&lt;Stat&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------- | ---- | ---------------- |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
| callback | AsyncCallback&lt;[Stat](#stat)&gt; | 是 | 异步获取文件状态信息之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------- | ---- | ---------------- |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
| callback | AsyncCallback&lt;[Stat](#stat)&gt; | 是 | 异步获取文件状态信息之后的回调。 |
**示例:**
```js
......@@ -1138,14 +1139,14 @@ fstatSync(fd: number): Stat
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待获取文件状态的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件状态的具体信息。 |
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件状态的具体信息。 |
**示例:**
```js
......@@ -1163,15 +1164,15 @@ ftruncate(fd: number, len?: number): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。|
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。|
**示例:**
```js
......@@ -1193,11 +1194,11 @@ ftruncate(fd: number, len: number, callback:AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 是 | 文件截断后的长度,以字节为单位。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,本调用无返回值。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 是 | 文件截断后的长度,以字节为单位。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,本调用无返回值。 |
**示例:**
```js
......@@ -1216,10 +1217,10 @@ ftruncateSync(fd: number, len?: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------- |
| fd | number | 是 | 待截断文件的文件描述符。 |
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
**示例:**
```js
......@@ -1242,9 +1243,9 @@ truncate(path: string, len?: number): Promise&lt;void&gt;
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1318,9 +1319,9 @@ readText(filePath: string, options?: {
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;encoding,string类型,当数据是&nbsp;string&nbsp;类型时有效,表示数据的编码方式,默认&nbsp;'utf-8',仅支持&nbsp;'utf-8'。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | Promise对象。返回读取文件的内容。 |
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | Promise对象。返回读取文件的内容。 |
**示例:**
```js
......@@ -1378,9 +1379,9 @@ readTextSync(filePath: string, options?: {
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读取。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;encoding,string类型,当数据是&nbsp;string&nbsp;类型时有效,表示数据的编码方式,默认&nbsp;'utf-8',仅支持&nbsp;'utf-8'。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------------------- |
| string | 返回读取文件的内容。 |
| 类型 | 说明 |
| ------ | -------------------- |
| string | 返回读取文件的内容。 |
**示例:**
```js
......@@ -1402,9 +1403,9 @@ lstat(path: string): Promise&lt;Stat&gt;
| path | string | 是 | 目标文件的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | promise对象,返回文件对象,表示文件的具体信息,详情见stat。 |
| 类型 | 说明 |
| ---------------------------- | ---------- |
| Promise&lt;[Stat](#stat)&gt; | promise对象,返回文件对象,表示文件的具体信息,详情见stat。 |
**示例:**
```js
......@@ -1452,9 +1453,9 @@ lstatSync(path:string): Stat
| path | string | 是 | 目标文件的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件的具体信息。 |
| 类型 | 说明 |
| ------------- | ---------- |
| [Stat](#stat) | 表示文件的具体信息。 |
**示例:**
```js
......@@ -1475,15 +1476,15 @@ read(buffer: ArrayBuffer, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
......@@ -1509,11 +1510,11 @@ read(buffer: ArrayBuffer, options: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步从文件读取数据之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于保存读取到的文件数据的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步从文件读取数据之后的回调。 |
**示例:**
```js
......@@ -1542,9 +1543,9 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt;
| newPath | String | 是 | 目标文件的新应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1607,14 +1608,14 @@ fsync(fd: number): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1635,10 +1636,10 @@ fsync(fd: number, callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | --------------- |
| fd | number | 是 | 待同步文件的文件描述符。 |
| Callback | AsyncCallback&lt;void&gt; | 是 | 异步将文件数据同步之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | --------------- |
| fd | number | 是 | 待同步文件的文件描述符。 |
| Callback | AsyncCallback&lt;void&gt; | 是 | 异步将文件数据同步之后的回调。 |
**示例:**
```js
......@@ -1657,9 +1658,9 @@ fsyncSync(fd: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
**示例:**
```js
......@@ -1676,14 +1677,14 @@ fdatasync(fd: number): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1704,10 +1705,10 @@ fdatasync(fd: number, callback:AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ----------------- |
| fd | number | 是 | 待同步文件的文件描述符。 |
| callback | AsyncCallback&nbsp;&lt;void&gt; | 是 | 异步将文件内容数据同步之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ----------------- |
| fd | number | 是 | 待同步文件的文件描述符。 |
| callback | AsyncCallback&nbsp;&lt;void&gt; | 是 | 异步将文件内容数据同步之后的回调。 |
**示例:**
```js
......@@ -1726,9 +1727,9 @@ fdatasyncSync(fd: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待同步文件的文件描述符。 |
**示例:**
```js
......@@ -1751,9 +1752,9 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt;
| srcPath | string | 是 | 符号链接文件的应用沙箱路径。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1824,9 +1825,9 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
| gid | number | 是 | 新的GID(GroupID)。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1895,14 +1896,14 @@ mkdtemp(prefix: string): Promise&lt;string&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | Promise对象。返回生成的唯一目录路径。 |
| 类型 | 说明 |
| --------------------- | ---------- |
| Promise&lt;string&gt; | Promise对象。返回生成的唯一目录路径。 |
**示例:**
```js
......@@ -1923,10 +1924,10 @@ mkdtemp(prefix: string, callback: AsyncCallback&lt;string&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步创建临时目录之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步创建临时目录之后的回调。 |
**示例:**
```js
......@@ -1945,14 +1946,14 @@ mkdtempSync(prefix: string): string
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| prefix | string | 是 | 用随机产生的字符串替换以“XXXXXX”结尾目录路径。 |
**返回值:**
| 类型 | 说明 |
| ------ | ---------- |
| string | 产生的唯一目录路径。 |
| 类型 | 说明 |
| ------ | ---------- |
| string | 产生的唯一目录路径。 |
**示例:**
```js
......@@ -1969,15 +1970,15 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -1998,11 +1999,11 @@ fchmod(fd: number, mode: number, callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
| callback | AsyncCallback&nbsp;&lt;void&gt; | 是 | 异步改变文件权限之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
| callback | AsyncCallback&nbsp;&lt;void&gt; | 是 | 异步改变文件权限之后的回调。 |
**示例:**
```js
......@@ -2021,10 +2022,10 @@ fchmodSync(fd: number, mode: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。<br/>-&nbsp;0o700:所有者具有读、写及可执行权限。<br/>-&nbsp;0o400:所有者具有读权限。<br/>-&nbsp;0o200:所有者具有写权限。<br/>-&nbsp;0o100:所有者具有可执行权限。<br/>-&nbsp;0o070:所有用户组具有读、写及可执行权限。<br/>-&nbsp;0o040:所有用户组具有读权限。<br/>-&nbsp;0o020:所有用户组具有写权限。<br/>-&nbsp;0o010:所有用户组具有可执行权限。<br/>-&nbsp;0o007:其余用户具有读、写及可执行权限。<br/>-&nbsp;0o004:其余用户具有读权限。<br/>-&nbsp;0o002:其余用户具有写权限。<br/>-&nbsp;0o001:其余用户具有可执行权限。 |
**示例:**
```js
......@@ -2047,9 +2048,9 @@ createStream(path: string, mode: string): Promise&lt;Stream&gt;
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
**返回值:**
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
**示例:**
```js
......@@ -2099,9 +2100,9 @@ createStreamSync(path: string, mode: string): Stream
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | --------- |
| [Stream](#stream7) | 返回文件流的结果。 |
| 类型 | 说明 |
| ------------------ | --------- |
| [Stream](#stream7) | 返回文件流的结果。 |
**示例:**
```js
......@@ -2118,15 +2119,15 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
**返回值:**
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
| 类型 | 说明 |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise对象。返回文件流的结果。 |
**示例:**
```js
......@@ -2148,11 +2149,11 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback&lt;Stream&gt;): v
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
| callback | AsyncCallback&nbsp;&lt;[Stream](#stream7)&gt; | 是 | 异步打开文件流之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
| callback | AsyncCallback&nbsp;&lt;[Stream](#stream7)&gt; | 是 | 异步打开文件流之后的回调。 |
**示例:**
```js
......@@ -2172,15 +2173,15 @@ fdopenStreamSync(fd: number, mode: string): Stream
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| fd | number | 是 | 待打开文件的文件描述符。 |
| mode | string | 是 | -&nbsp;r:打开只读文件,该文件必须存在。<br/>-&nbsp;r+:打开可读写的文件,该文件必须存在。<br/>-&nbsp;w:打开只写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;w+:打开可读写文件,若文件存在则文件长度清0,即该文件内容会消失。若文件不存在则建立该文件。<br/>-&nbsp;a:以附加的方式打开只写文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾,即文件原先的内容会被保留。<br/>-&nbsp;a+:以附加方式打开可读写的文件。若文件不存在,则会建立该文件,如果文件存在,写入的数据会被加到文件尾后,即文件原先的内容会被保留。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | --------- |
| [Stream](#stream7) | 返回文件流的结果。 |
| 类型 | 说明 |
| ------------------ | --------- |
| [Stream](#stream7) | 返回文件流的结果。 |
**示例:**
```js
......@@ -2198,16 +2199,16 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -2229,12 +2230,12 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | --------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步改变文件所有者之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | --------------- |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步改变文件所有者之后的回调。 |
**示例:**
```js
......@@ -2254,11 +2255,11 @@ fchownSync(fd: number, uid: number, gid: number): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ------------ |
| fd | number | 是 | 待改变文件的文件描述符。 |
| uid | number | 是 | 文件所有者的UID。 |
| gid | number | 是 | 文件所有组的GID。 |
**示例:**
```js
......@@ -2283,9 +2284,9 @@ lchown(path: string, uid: number, gid: number): Promise&lt;void&gt;
| gid | number | 是 | 新的GID。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**示例:**
```js
......@@ -2361,9 +2362,9 @@ createWatcher(filename: string, events: number, callback: AsyncCallback&lt;numbe
| callback | AsyncCallback&lt;number&nbsp;&gt; | 是 | 每发生变化一次,调用一次此函数。 |
**返回值:**
| 类型 | 说明 |
| -------------------- | ---------- |
| [Watcher](#watcher7) | Promise对象。返回文件变化监听的实例。 |
| 类型 | 说明 |
| -------------------- | ---------- |
| [Watcher](#watcher7) | Promise对象。返回文件变化监听的实例。 |
**示例:**
```js
......@@ -2421,9 +2422,9 @@ isBlockDevice(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ---------------- |
| boolean | 表示文件是否是块特殊设备。 |
| 类型 | 说明 |
| ------- | ---------------- |
| boolean | 表示文件是否是块特殊设备。 |
**示例:**
```js
......@@ -2440,9 +2441,9 @@ isCharacterDevice(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ----------------- |
| boolean | 表示文件是否是字符特殊设备。 |
| 类型 | 说明 |
| ------- | ----------------- |
| boolean | 表示文件是否是字符特殊设备。 |
**示例:**
```js
......@@ -2459,9 +2460,9 @@ isDirectory(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ------------- |
| boolean | 表示文件是否是目录。 |
| 类型 | 说明 |
| ------- | ------------- |
| boolean | 表示文件是否是目录。 |
**示例:**
```js
......@@ -2478,9 +2479,9 @@ isFIFO(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------------- |
| boolean | 表示文件是否是&nbsp;FIFO。 |
| 类型 | 说明 |
| ------- | --------------------- |
| boolean | 表示文件是否是&nbsp;FIFO。 |
**示例:**
```js
......@@ -2497,9 +2498,9 @@ isFile(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示文件是否是普通文件。 |
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示文件是否是普通文件。 |
**示例:**
```js
......@@ -2516,9 +2517,9 @@ isSocket(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | -------------- |
| boolean | 表示文件是否是套接字。 |
| 类型 | 说明 |
| ------- | -------------- |
| boolean | 表示文件是否是套接字。 |
**示例:**
```js
......@@ -2535,9 +2536,9 @@ isSymbolicLink(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示文件是否是符号链接。 |
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示文件是否是符号链接。 |
**示例:**
```js
......@@ -2579,9 +2580,9 @@ stop(callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 以异步方法关闭watcher监听之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 以异步方法关闭watcher监听之后的回调。 |
**示例:**
```js
......@@ -2609,9 +2610,9 @@ close(): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise对象。返回表示异步关闭文件流的结果。 |
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise对象。返回表示异步关闭文件流的结果。 |
**示例:**
```js
......@@ -2633,9 +2634,9 @@ close(callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件流之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步关闭文件流之后的回调。 |
**示例:**
```js
......@@ -2670,9 +2671,9 @@ flush(): Promise&lt;void&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise对象。返回表示异步刷新文件流的结果。 |
| 类型 | 说明 |
| ------------------- | ------------- |
| Promise&lt;void&gt; | Promise对象。返回表示异步刷新文件流的结果。 |
**示例:**
```js
......@@ -2694,9 +2695,9 @@ flush(callback: AsyncCallback&lt;void&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步刷新文件流后的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;void&gt; | 是 | 异步刷新文件流后的回调函数。 |
**示例:**
```js
......@@ -2736,15 +2737,15 @@ write(buffer: ArrayBuffer | string, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
| 类型 | 说明 |
| --------------------- | -------- |
| Promise&lt;number&gt; | Promise对象。返回实际写入的长度。 |
**示例:**
```js
......@@ -2771,11 +2772,11 @@ write(buffer: ArrayBuffer | string, options: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 异步写入完成后执行的回调函数。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 异步写入完成后执行的回调函数。 |
**示例:**
```js
......@@ -2803,15 +2804,15 @@ writeSync(buffer: ArrayBuffer | string, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer&nbsp;\|&nbsp;string | 是 | 待写入文件的数据,可来自缓冲区或字符串。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示期望写入数据的位置相对于数据首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望写入数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望写入文件的位置。可选,默认从当前位置开始写。<br/>-&nbsp;encoding,string类型,当数据是string类型时有效,表示数据的编码方式,默认&nbsp;'utf-8'。仅支持&nbsp;'utf-8'。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------- |
| number | 实际写入的长度。 |
| 类型 | 说明 |
| ------ | -------- |
| number | 实际写入的长度。 |
**示例:**
```js
......@@ -2833,15 +2834,15 @@ read(buffer: ArrayBuffer, options?: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
| 类型 | 说明 |
| ---------------------------------- | ------ |
| Promise&lt;[ReadOut](#readout)&gt; | Promise对象。返回读取的结果。 |
**示例:**
```js
......@@ -2868,11 +2869,11 @@ read(buffer: ArrayBuffer, options: {
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步从流文件读取数据之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| callback | AsyncCallback&lt;[ReadOut](#readout)&gt; | 是 | 异步从流文件读取数据之后的回调。 |
**示例:**
```js
......@@ -2900,16 +2901,16 @@ readSync(buffer: ArrayBuffer, options?: {
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ----------- | ---- | ---------------------------------------- |
| buffer | ArrayBuffer | 是 | 用于读取文件的缓冲区。 |
| options | Object | 否 | 支持如下选项:<br/>-&nbsp;offset,number类型,表示将数据读取到缓冲区的位置,即相对于缓冲区首地址的偏移。可选,默认为0。<br/>-&nbsp;length,number类型,表示期望读取数据的长度。可选,默认缓冲区长度减去偏移长度。<br/>-&nbsp;position,number类型,表示期望读取文件的位置。可选,默认从当前位置开始读。<br/>约束:offset+length<=buffer.size。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------- |
| number | 实际读取的长度。 |
| 类型 | 说明 |
| ------ | -------- |
| number | 实际读取的长度。 |
**示例:**
```js
......@@ -2932,9 +2933,9 @@ read(): Promise&lt;Dirent&gt;
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| -------------------------------- | ------------- |
| Promise&lt;[Dirent](#dirent)&gt; | Promise对象。返回表示异步读取目录项的结果。 |
| 类型 | 说明 |
| -------------------------------- | ------------- |
| Promise&lt;[Dirent](#dirent)&gt; | Promise对象。返回表示异步读取目录项的结果。 |
**示例:**
```js
......@@ -2956,9 +2957,9 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback&lt;[Dirent](#dirent)&gt; | 是 | 异步读取下一个目录项之后的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback&lt;[Dirent](#dirent)&gt; | 是 | 异步读取下一个目录项之后的回调。 |
**示例:**
```js
......@@ -2981,9 +2982,9 @@ readSync(): Dirent
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ----------------- | -------- |
| [Dirent](#dirent) | 表示一个目录项。 |
| 类型 | 说明 |
| ----------------- | -------- |
| [Dirent](#dirent) | 表示一个目录项。 |
**示例:**
```js
......@@ -3063,9 +3064,9 @@ isBlockDevice(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ---------------- |
| boolean | 表示当前目录项是否是块特殊设备。 |
| 类型 | 说明 |
| ------- | ---------------- |
| boolean | 表示当前目录项是否是块特殊设备。 |
**示例:**
```js
......@@ -3083,9 +3084,9 @@ isCharacterDevice(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ----------------- |
| boolean | 表示当前目录项是否是字符特殊设备。 |
| 类型 | 说明 |
| ------- | ----------------- |
| boolean | 表示当前目录项是否是字符特殊设备。 |
**示例:**
```js
......@@ -3103,9 +3104,9 @@ isDirectory(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | ------------- |
| boolean | 表示当前目录项是否是目录。 |
| 类型 | 说明 |
| ------- | ------------- |
| boolean | 表示当前目录项是否是目录。 |
**示例:**
```js
......@@ -3123,9 +3124,9 @@ isFIFO(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是FIFO。 |
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是FIFO。 |
**示例:**
```js
......@@ -3143,9 +3144,9 @@ isFile(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是普通文件。 |
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是普通文件。 |
**示例:**
```js
......@@ -3163,9 +3164,9 @@ isSocket(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | -------------- |
| boolean | 表示当前目录项是否是套接字。 |
| 类型 | 说明 |
| ------- | -------------- |
| boolean | 表示当前目录项是否是套接字。 |
**示例:**
```js
......@@ -3183,9 +3184,9 @@ isSymbolicLink(): boolean
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是符号链接。 |
| 类型 | 说明 |
| ------- | --------------- |
| boolean | 表示当前目录项是否是符号链接。 |
**示例:**
```js
......
# 公共文件访问与管理
该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
>![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
>- 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>- 本模块接口为系统接口,三方应用不支持调用,当前只支持filepicker调用。
该模块提供公共文件访问和管理的服务接口,向下对接底层文件管理服务,如媒体库、外卡管理;向上对应用程序提供公共文件查询、创建的能力。
## 导入模块
```js
......
# 国际化-I18n
本模块提供系统相关的或者增强的国际化能力,包括区域管理、电话号码处理、日历等,相关接口为ECMA 402标准中未定义的补充接口。
[Intl模块](js-apis-intl.md)提供了ECMA 402标准定义的基础国际化接口,与本模块共同使用可提供完整地国际化支持能力。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
......
# 图片处理
本模块提供图片处理效果,包括通过属性创建PixelMap、读取图像像素数据、读取区域内的图片数据等。
> **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# 输入法框架
本模块提供对输入法框架的管理,包括隐藏输入法、查询已安装的输入法列表和显示输入法选择对话框。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......@@ -47,7 +49,7 @@ getInputMethodController(): InputMethodController
| [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 |
**示例:**
```js
var InputMethodController = inputMethod.getInputMethodController();
```
......@@ -62,9 +64,9 @@ getInputMethodSetting(): InputMethodSetting
**返回值:**
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#InputMethodSetting) | 回调返回当前客户端设置实例。 |
| 类型 | 说明 |
| ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#InputMethodSetting) | 回调返回当前客户端设置实例。 |
**示例:**
......@@ -87,9 +89,9 @@ stopInput(callback: AsyncCallback&lt;boolean&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法隐藏是否成功。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 返回输入法隐藏是否成功。 |
**示例:**
......@@ -109,9 +111,9 @@ stopInput(): Promise&lt;boolean&gt;
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 返回输入法隐藏是否成功。 |
| 类型 | 说明 |
| -------- | -------- |
| Promise&lt;boolean&gt; | 返回输入法隐藏是否成功。 |
**示例:**
......@@ -134,12 +136,12 @@ listInputMethod(callback: AsyncCallback&lt;Array&lt;InputMethodProperty&gt;&gt;)
**系统能力**: SystemCapability.Miscservices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 |
**示例:**
```js
InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) {
......@@ -158,9 +160,9 @@ listInputMethod(): Array&lt;InputMethodProperty&gt;
**系统能力**: SystemCapability.Miscservices.InputMethodFramework
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 |
| 类型 | 说明 |
| ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | 返回已安装输入法列表。 |
**示例:**
......
# 国际化-Intl
本模块提供提供基础的应用国际化能力,包括时间日期格式化、数字格式化、排序等,相关接口在ECMA 402标准中定义。
[I18N模块](js-apis-i18n.md)提供其他非ECMA 402定义的国际化接口,与本模块共同使用可提供完整地国际化支持能力。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
......
# 日志打印
本模块提供日志打印能力,包括打印debug级别的日志信息、打印info级别的日志信息、打印warn级别的日志信息和打印error级别的日志信息。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从API Version 7 开始,该接口不再维护,推荐使用新接口[`@ohos.hilog`](js-apis-hilog.md)。
......
# 媒体查询
提供根据不同媒体类型定义不同的样式。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 弹窗
创建并显示文本提示框、对话框和操作菜单。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
......@@ -2,7 +2,8 @@
资源管理模块,根据当前configuration(语言,区域,横竖屏,mccmnc)和device capability(设备类型,分辨率)提供获取应用资源信息读取接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
>
> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......@@ -238,7 +239,7 @@ resourceManager.getResourceManager((error, mgr) => {
| offset | number | rawfile的起始偏移量 |
| length | number | rawfile的文件长度 |
## Resource
## Resource<sup>9+</sup>
表示的资源信息。
......@@ -255,7 +256,8 @@ resourceManager.getResourceManager((error, mgr) => {
提供访问应用资源的能力。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> **说明:**
>
> - ResourceManager涉及到的方法,仅限基于TS扩展的声明式开发范式使用。
>
> - 资源文件在工程的resources目录中定义,id可通过$r(资源地址).id的方式获取,例如$r('app.string.test').id。
......@@ -330,7 +332,7 @@ getString(resource: Resource, callback: AsyncCallback&lt;string&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回获取的字符串 |
**示例:**
......@@ -360,7 +362,7 @@ getString(resource: Resource): Promise&lt;string&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -449,7 +451,7 @@ getStringArray(resource: Resource, callback: AsyncCallback&lt;Array&lt;string&gt
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 异步回调,用于返回获取的字符串数组 |
**示例:**
......@@ -479,7 +481,7 @@ getStringArray(resource: Resource): Promise&lt;Array&lt;string&gt;&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -568,7 +570,7 @@ getMedia(resource: Resource, callback: AsyncCallback&lt;Uint8Array&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| callback | AsyncCallback&lt;Uint8Array&gt; | 是 | 异步回调,用于返回获取的媒体文件内容 |
**示例:**
......@@ -598,7 +600,7 @@ getMedia(resource: Resource): Promise&lt;Uint8Array&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -687,7 +689,7 @@ getMediaBase64(resource: Resource, callback: AsyncCallback&lt;string&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------ |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,用于返回获取的图片资源Base64编码 |
**示例:**
......@@ -717,7 +719,7 @@ getMediaBase64(resource: Resource): Promise&lt;string&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -917,7 +919,7 @@ getPluralString(resource: Resource, num: number, callback: AsyncCallback&lt;stri
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| num | number | 是 | 数量值 |
| callback | AsyncCallback&lt;string&gt; | 是 | 异步回调,返回根据指定数量获取指定resource对象表示的单复数字符串 |
......@@ -948,7 +950,7 @@ getPluralString(resource: Resource, num: number): Promise&lt;string&gt;
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
| num | number | 是 | 数量值 |
**返回值:**
......@@ -1451,7 +1453,7 @@ getStringSync(resource: Resource): string
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -1524,7 +1526,7 @@ getBoolean(resource: Resource): boolean
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......@@ -1599,7 +1601,7 @@ getNumber(resource: Resource): number
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----- |
| resource | [Resource](#resource) | 是 | 资源信息 |
| resource | [Resource](#resource9) | 是 | 资源信息 |
**返回值:**
| 类型 | 说明 |
......
# 页面路由
本模块提供通过不同的url访问不同的页面,包括跳转到应用内的指定页面、用应用内的某个页面替换当前页面、返回上一页面或指定的页面等。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
# 数据标签
该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
该模块提供文件数据安全等级的相关功能:向应用程序提供查询、设置文件数据安全等级的JS接口。
## 导入模块
```js
......
# statfs
该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
该模块提供文件系统相关存储信息的功能,向应用程序提供获取文件系统总字节数、空闲字节数的JS接口。
## 导入模块
```js
......
# 应用空间统计
该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
该模块提供空间查询相关的常用功能:包括对内外卡的空间查询,对应用分类数据统计的查询,对应用数据的查询等。
## 导入模块
```js
......
# 媒体查询
提供根据不同媒体类型定义不同的样式。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
......
# 弹窗
创建并显示文本提示框、对话框和操作菜单。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 从API Version 8 开始,该接口不再维护,推荐使用新接口[`@ohos.prompt`](js-apis-prompt.md)。
......
# 页面路由
通过不同的uri访问不同的页面。
> **说明:**
>
> - 从API Version 8 开始,该接口不再维护,推荐使用新接口[`@ohos.router`](js-apis-router.md)。
......
# 卷管理
该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
>
> - 本模块首批接口从API version 9开始支持。
> - API 9当前为Canary版本,仅供试用,不保证接口可稳定调用。
> - 本模块接口为系统接口,三方应用不支持调用。
该模块提供卷、磁盘查询和管理的相关功能:包括查询卷信息,对卷的挂载卸载、对磁盘分区以及卷的格式化等功能。
## 导入模块
```js
......
......@@ -53,7 +53,7 @@
| [start&nbsp;\|&nbsp;end]<sup>6+</sup> | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt; | - | start&nbsp;\|&nbsp;end需要配合position样式使用,来确定元素的偏移位置。<br/>-&nbsp;start属性规定元素的起始边缘。该属性定义了定位元素起始外边距边界与其包含块起始边界之间的偏移。<br/>-&nbsp;end属性规定元素的结尾边缘。该属性定义了一个定位元素的结尾边距边界与其包含块结尾边界之间的偏移。 |
| z-index<sup>6+</sup> | number | - | 表示对于同一父节点其子节点的渲染顺序。数值越大,渲染数据越靠后。<br/>z-index不支持auto,并且opacity等其他样式不会影响z-index的渲染顺序。 |
| image-fill<sup>6+</sup> | &lt;color&gt; | - | 为svg图片填充颜色,支持组件范围(与设置图片资源的属性):button(icon属性)、piece(icon属性)、search(icon属性)、input(headericon属性)、textarea(headericon属性)、image(src属性)、toolbar-item(icon属性)。<br/>svg图片文件内的fill属性颜色值在渲染时将被替换为image-fill所配的颜色值,且仅对svg图片内显示声明的fill属性生效。 |
| clip-path<sup>6+</sup> | [&nbsp;&lt;geometry-box&gt;&nbsp;\|\|&nbsp;&lt;basic-shape&gt;&nbsp;]&nbsp;\|&nbsp;none | - | 设置组件的裁剪区域。区域内的部分显示,区域外的不显示。<br/>&lt;geometry-box&gt;:表示裁剪区域的作用范围,默认为border-box。可选值为:<br/>-&nbsp;margin-box:margin计算入长宽尺寸内。<br/>-&nbsp;border-box:border计算入长宽尺寸内。<br/>-&nbsp;padding-box:padding计算入长宽尺寸内。<br/>-&nbsp;content-box:margin/border/padding不计算入长宽尺寸内。<br/>&lt;basic-shape&gt;:表示裁剪的形状。包含以下类型:<br/>-&nbsp;inset,格式为:inset(&nbsp;&lt;percentage&gt;{1,4}&nbsp;[&nbsp;round&nbsp;&lt;'border-radius'&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;circle,格式为:circle(&nbsp;[&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;[&nbsp;at&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;ellipse,格式为:ellipse(&nbsp;[&nbsp;&lt;percentage&gt;{2}&nbsp;]?&nbsp;[&nbsp;at&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;polygon,格式为:polygon(&nbsp;[&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]\#&nbsp;)<br/>-&nbsp;path,格式为:path(&nbsp;&lt;string&gt;&nbsp;)。 |
| clip-path<sup>6+</sup> | [&nbsp;&lt;geometry-box&gt;&nbsp;\|&nbsp;&lt;basic-shape&gt;&nbsp;]&nbsp;\|&nbsp;none | - | 设置组件的裁剪区域。区域内的部分显示,区域外的不显示。<br/>&lt;geometry-box&gt;:表示裁剪区域的作用范围,默认为border-box。可选值为:<br/>-&nbsp;margin-box:margin计算入长宽尺寸内。<br/>-&nbsp;border-box:border计算入长宽尺寸内。<br/>-&nbsp;padding-box:padding计算入长宽尺寸内。<br/>-&nbsp;content-box:margin/border/padding不计算入长宽尺寸内。<br/>&lt;basic-shape&gt;:表示裁剪的形状。包含以下类型:<br/>-&nbsp;inset,格式为:inset(&nbsp;&lt;percentage&gt;{1,4}&nbsp;[&nbsp;round&nbsp;&lt;'border-radius'&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;circle,格式为:circle(&nbsp;[&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;[&nbsp;at&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;ellipse,格式为:ellipse(&nbsp;[&nbsp;&lt;percentage&gt;{2}&nbsp;]?&nbsp;[&nbsp;at&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]?&nbsp;)。<br/>-&nbsp;polygon,格式为:polygon(&nbsp;[&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt;&nbsp;]\#&nbsp;)<br/>-&nbsp;path,格式为:path(&nbsp;&lt;string&gt;&nbsp;)。 |
| mask-image<sup>6+</sup> | -&nbsp;&lt;linear-gradient&gt;<br/>-&nbsp;string | - | 设置渐变色遮罩或本地图片设置。<br/>设置渐变色遮罩,示例:<br/>linear-gradient(to&nbsp;left,&nbsp;black,&nbsp;white)<br/>设置纯色遮罩,示例:<br/>linear-gradient(to&nbsp;right,&nbsp;grey&nbsp;,&nbsp;grey)<br/>设置本地svg图片为遮罩,示例:url(common/mask.svg) |
| mask-size<sup>6+</sup> | -&nbsp;string<br/>-&nbsp;&lt;length&gt;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | auto | 设置遮罩图片显示大小,仅当mask-image为图片资源时有效。<br/>string可选值:<br/>-&nbsp;contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。<br/>-&nbsp;cover:把图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。<br/>-&nbsp;auto:保持原图的比例不变。<br/>length值参数方式:设置图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。<br/>百分比参数方式:以原图宽高的百分比来设置图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为&nbsp;"auto"。 |
| mask-position<sup>6+</sup> | -&nbsp;string&nbsp;string<br/>-&nbsp;&lt;length&gt;&nbsp;&lt;length&gt;<br/>-&nbsp;&lt;percentage&gt;&nbsp;&lt;percentage&gt; | 0px&nbsp;0px | 设置遮罩图片显示位置,仅当mask-image为图片资源时有效。关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。<br/>string可选值:<br/>-&nbsp;left:水平方向上最左侧。<br/>-&nbsp;right:水平方向上最右侧。<br/>-&nbsp;top:竖直方向上最顶部。<br/>-&nbsp;bottom:竖直方向上最底部。<br/>-&nbsp;center:水平方向或竖直方向上中间位置。<br/>length值参数方式:第一个值是水平位置,第二个值是垂直位置。&nbsp;左上角是&nbsp;0&nbsp;0。单位是像素&nbsp;(0px&nbsp;0px)&nbsp;&nbsp;。如果仅规定了一个值,另外一个值将是50%。<br/>百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是&nbsp;0%&nbsp;0%。右下角是&nbsp;100%&nbsp;100%。如果仅规定了一个值,另外一个值为50%。<br/>可以混合使用&lt;percentage&gt;&lt;length&gt;。 |
......
# Button
按钮组件,可快速创建不同样式的按钮。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
提供按钮组件。
## 权限列表
......@@ -23,10 +22,10 @@
**表1** options参数说明
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| type | ButtonType | 否 | Capsule | 描述按钮风格。 |
| stateEffect | boolean | 否 | true | 按钮按下时是否开启切换效果,当状态置为false时,点击效果关闭。 |
| type | ButtonType | 否 | Capsule | 描述按钮风格。 |
| stateEffect | boolean | 否 | true | 按钮按下时是否开启切换效果,当状态置为false时,点击效果关闭。 |
- Button(label?: string, options?: { type?: ButtonType, stateEffect?: boolean })
......@@ -49,11 +48,11 @@
| stateEffect | boolean | true | 状态切换时是否开启切换效果,当状态置为false时,点击效果关闭。 |
- ButtonType枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Capsule | 胶囊型按钮(圆角默认为高度的一半)。 |
| Circle | 圆形按钮。 |
| Normal | 普通按钮(默认不带圆角)。 |
| Capsule | 胶囊型按钮(圆角默认为高度的一半)。 |
| Circle | 圆形按钮。 |
| Normal | 普通按钮(默认不带圆角)。 |
> **说明:**
> - 按钮圆角通过[通用属性borderRadius设置](ts-universal-attributes-border.md)(不支持通过border接口设置圆角)。
......
# LoadingProgress
用于显示加载动效的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
用于显示加载进展。
## 权限列表
......
# QRCode
用于显示单个二维码的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
显示二维码信息。
## 权限列表
......@@ -22,16 +21,16 @@
QRCode(value: string)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| value | string | 是 | - | 二维码内容字符串。 |
| value | string | 是 | - | 二维码内容字符串。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| color | Color | Black | 设置二维码颜色。 |
| color | Color | Black | 设置二维码颜色。 |
## 事件
......
# Rating
提供在给定范围内选择评分的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
评分条组件。
## 权限列表
......@@ -22,26 +21,26 @@
Rating(options?: { rating: number, indicator?: boolean })
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| rating | number | 是 | 0 | 设置并接收评分值。 |
| indicator | boolean | 否 | false | 仅作为指示器使用,不可操作。 |
| rating | number | 是 | 0 | 设置并接收评分值。 |
| indicator | boolean | 否 | false | 仅作为指示器使用,不可操作。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| stars | number | 5 | 设置评星总数。 |
| stepSize | number | 0.5 | 操作评级的步长。 |
| starStyle | {<br/>backgroundUri:&nbsp;string,<br/>foregroundUri:&nbsp;string,<br/>secondaryUri?:&nbsp;string<br/>} | - | backgroundSrc:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地。<br/>foregroundSrc:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。<br/>secondarySrc:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。 |
| stars | number | 5 | 设置评星总数。 |
| stepSize | number | 0.5 | 操作评级的步长。 |
| starStyle | {<br/>backgroundUri:&nbsp;string,<br/>foregroundUri:&nbsp;string,<br/>secondaryUri?:&nbsp;string<br/>} | - | backgroundSrc:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地。<br/>foregroundSrc:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。<br/>secondarySrc:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onChange(callback:(value:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 操作评分条的评星发生改变时触发该回调。 |
| onChange(callback:(value:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 操作评分条的评星发生改变时触发该回调。 |
## 示例
......
# Span
作为Text组件的子组件,用于显示行内文本的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
文本段落,只能作为Text子组件,呈现一段文本信息。
## 权限列表
......@@ -22,9 +21,9 @@
Span(content: string)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| content | string | 是 | - | 文本内容。 |
| content | string | 是 | - | 文本内容。 |
## 属性
......
# Stepper
应用步骤方式切换页面的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
步骤导航器。
## 权限列表
......@@ -24,9 +23,9 @@ Stepper(value?: { index?: number })
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| index | number | 否 | 0 | 设置步骤导航器显示第几个StepperItem。 |
| index | number | 否 | 0 | 设置步骤导航器显示第几个StepperItem。 |
## 属性
......@@ -36,11 +35,11 @@ Stepper(value?: { index?: number })
## 事件
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| onFinish(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 步骤导航器最后一个StepperItem的nextLabel被点击时触发该回调&nbsp;。 |
| onSkip(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 |
| onChange(callback:&nbsp;(prevIndex?:&nbsp;number,&nbsp;index?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击左边或者右边文本按钮进行步骤切换时触发该事件。<br/>-&nbsp;prevIndex:切换前的步骤页索引值。<br/>-&nbsp;index:切换后的步骤页(前一页或者下一页)索引值。 |
| onFinish(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 步骤导航器最后一个StepperItem的nextLabel被点击时触发该回调&nbsp;。 |
| onSkip(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 当前显示的StepperItem状态为ItemState.Skip时,nextLabel被点击时触发该回调。 |
| onChange(callback:&nbsp;(prevIndex?:&nbsp;number,&nbsp;index?:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 点击左边或者右边文本按钮进行步骤切换时触发该事件。<br/>-&nbsp;prevIndex:切换前的步骤页索引值。<br/>-&nbsp;index:切换后的步骤页(前一页或者下一页)索引值。 |
## 示例
......
# StepperItem
用作[Stepper](ts-basic-components-stepper.md)组件的页面子组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
步骤导航器元素。
## 权限列表
......@@ -32,12 +31,12 @@ StepperItem()
| status | ItemState | ItemState.Normal | 步骤导航器元素的状态。 |
- ItemState枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 |
| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 |
| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 |
| Skip | 跳过状态,表示跳过当前步骤,&nbsp;进入下一个StepperItem。 |
| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 |
| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 |
| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 |
| Skip | 跳过状态,表示跳过当前步骤,&nbsp;进入下一个StepperItem。 |
## 示例
......
# Text
显示一段文本的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
文本,用于呈现一段信息。
## 权限列表
......@@ -22,9 +21,9 @@
Text(content?: string)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| content | string | 否 | '' | 文本内容,包含子组件Span时不生效,显示Span内容。 |
| content | string | 否 | '' | 文本内容,包含子组件Span时不生效,显示Span内容。 |
## 属性
......@@ -41,26 +40,26 @@ Text(content?: string)
| copyOption<sup>9+</sup> | boolean\|CopyOption | false | 组件支持设置文本是否可复制粘贴。 |
- TextAlign枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Center | 文本居中对齐。 |
| Start | 根据文字书写相同的方向对齐。 |
| End | 根据文字书写相反的方向对齐。 |
| Center | 文本居中对齐。 |
| Start | 根据文字书写相同的方向对齐。 |
| End | 根据文字书写相反的方向对齐。 |
- TextOverflow枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Clip | 文本超长时进行裁剪显示。 |
| Ellipsis | 文本超长时显示不下的文本用省略号代替。 |
| None | 文本超长时不进行裁剪。 |
| Clip | 文本超长时进行裁剪显示。 |
| Ellipsis | 文本超长时显示不下的文本用省略号代替。 |
| None | 文本超长时不进行裁剪。 |
- TextDecorationType枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Underline | 文字下划线修饰。 |
| LineThrough | 穿过文本的修饰线。 |
| Overline | 文字上划线修饰。 |
| None | 不使用文本装饰线。 |
| Underline | 文字下划线修饰。 |
| LineThrough | 穿过文本的修饰线。 |
| Overline | 文字上划线修饰。 |
| None | 不使用文本装饰线。 |
- TextCase枚举说明
......
# TextArea
可以输入多行文本并支持响应部分输入事件的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
提供多行文本输入组件。
## 权限列表
......
# TextInput
可以输入单行文本并支持响应输入事件的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
提供单行文本输入组件。
## 权限列表
......
# TextPicker
滚动选择文本的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
文本类滑动选择器组件。
## 权限列表
......@@ -24,7 +23,7 @@ TextPicker(value: {range: string[] | Resource, value?: string, selected?: number
根据range指定的选择范围创建文本选择器。
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| range | string[]\|&nbsp;[Resource](../../ui/ts-types.md#resource类型) | 是 | - | 选择器的数据选择范围。 |
| value | string | 否 | - | 搜索文本值。 |
......@@ -33,16 +32,16 @@ TextPicker(value: {range: string[] | Resource, value?: string, selected?: number
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| defaultPickerItemHeight | Length | - | 默认Picker内容项元素高度。 |
| defaultPickerItemHeight | Length | - | 默认Picker内容项元素高度。 |
## 事件
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;string,&nbsp;index:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 滑动选中TextPicker文本内容后,触发该回调。<br/>-&nbsp;value:&nbsp;当前选中项的文本。<br/>-&nbsp;index:&nbsp;当前选中项的下标。 |
| onChange(callback:&nbsp;(value:&nbsp;string,&nbsp;index:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 滑动选中TextPicker文本内容后,触发该回调。<br/>-&nbsp;value:&nbsp;当前选中项的文本。<br/>-&nbsp;index:&nbsp;当前选中项的下标。 |
## 示例
......
# TextTimer
通过文本显示计时信息并控制其计时器状态的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
文本计时器组件,支持自定义时间格式。
## 权限列表
......@@ -22,24 +21,24 @@
TextTimer(options: { isCountDown?: boolean, count?: number, controller?: TextTimerController })
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| isCountDown | boolean | 否 | false | 是否倒计时。 |
| count | number | 否 | 60000 | 倒计时时间(isCountDown为true时生效),单位为毫秒。<br/>-&nbsp;count&lt;=0时,使用默认值为倒计时初始值。<br/>-&nbsp;count&gt;0时,count值为倒计时初始值。 |
| controller | [TextTimerController](#texttimercontroller) | 否 | null | TextTimer控制器。 |
| isCountDown | boolean | 否 | false | 是否倒计时。 |
| count | number | 否 | 60000 | 倒计时时间(isCountDown为true时生效),单位为毫秒。<br/>-&nbsp;count&lt;=0时,使用默认值为倒计时初始值。<br/>-&nbsp;count&gt;0时,count值为倒计时初始值。 |
| controller | [TextTimerController](#texttimercontroller) | 否 | null | TextTimer控制器。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| format | string | 'hh:mm:ss.ms' | 自定义格式,需至少包含一个hh、mm、ss、ms中的关键字。 |
| format | string | 'hh:mm:ss.ms' | 自定义格式,需至少包含一个hh、mm、ss、ms中的关键字。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onTimer(callback:&nbsp;(utc:&nbsp;number,&nbsp;elapsedTime:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 时间文本发生变化时触发。<br/>utc:当前显示的时间,单位为毫秒。<br/>elapsedTime:计时器经过的时间,单位为毫秒。 |
| onTimer(callback:&nbsp;(utc:&nbsp;number,&nbsp;elapsedTime:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 时间文本发生变化时触发。<br/>utc:当前显示的时间,单位为毫秒。<br/>elapsedTime:计时器经过的时间,单位为毫秒。 |
## TextTimerController
......
# TimePicker
滚动选择时间的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
选择时间的滑动选择器组件。
## 权限列表
......@@ -31,22 +30,22 @@ TimePicker(options?: TimePickerOptions)
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| useMilitaryTime | boolean | false | 展示时间是否为24小时制,不支持动态修改。 |
| useMilitaryTime | boolean | false | 展示时间是否为24小时制,不支持动态修改。 |
## 事件
| 名称 | 功能描述 |
| -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;TimePickerResult )&nbsp;=&gt;&nbsp;void) | 选择时间时触发该事件。 |
| 名称 | 功能描述 |
| -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;TimePickerResult )&nbsp;=&gt;&nbsp;void) | 选择时间时触发该事件。 |
### TimePickerResult对象说明
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| hour | number | 选中时间的时。 |
| minute | number | 选中时间的分。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| hour | number | 选中时间的时。 |
| minute | number | 选中时间的分。 |
## 示例
......
# Toggle
组件提供勾选框样式、状态按钮样式及开关样式。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -28,7 +30,7 @@ Toggle(options: { type: ToggleType, isOn?: boolean })
- ToggleType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Checkbox | 提供选框样式,子组件设置文本不生效,如需文本设置,可将Text和当前组件放入布局组件中。<br>>&nbsp;**说明:**<br/>>&nbsp;[通用属性padding](ts-universal-attributes-size.md)的默认值为:<br>{<br>&nbsp;top: 14 vp,<br>&nbsp;right: 6 vp,<br>&nbsp;bottom: 14 vp,<br>&nbsp;left: 6 vp<br> } |
| Checkbox | 提供选框样式,子组件设置文本不生效,如需文本设置,可将Text和当前组件放入布局组件中。<br>>&nbsp;**说明:**<br/>>&nbsp;[通用属性padding](ts-universal-attributes-size.md)的默认值为:<br>{<br>&nbsp;top: 14 vp,<br>&nbsp;right: 6 vp,<br>&nbsp;bottom: 14 vp,<br>&nbsp;left: 6 vp<br> } |
| Button | 提供状态按钮样式,如果有文本设置,则相应的文本内容会显示在按钮内部。 |
| Switch | 提供开关样式,子组件设置文本不生效,如需文本设置,可将Text和当前组件放入布局组件中。<br>>&nbsp;**说明:**<br/>>&nbsp;[通用属性padding](ts-universal-attributes-size.md)默认值为:<br>{<br/>&nbsp;top: 12 vp,<br/>&nbsp;right: 12 vp,<br/>&nbsp;bottom: 12 vp,<br/>&nbsp;left: 12 vp<br/> } |
......
# LongPressGesture
用于触发长按手势事件,触发长按手势的最少手指数为1,最短时间为500毫秒。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -14,25 +16,25 @@
LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: number })
- 参数
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| fingers | number | 否 | 1 | 触发长按的最少手指数,最小为1指,&nbsp;最大取值为10指。 |
| repeat | boolean | 否 | false | 是否连续触发事件回调。 |
| duration | number | 否 | 500 | 最小触发长按的时间,单位为毫秒(ms)。 |
| fingers | number | 否 | 1 | 触发长按的最少手指数,最小为1指,&nbsp;最大取值为10指。 |
| repeat | boolean | 否 | false | 是否连续触发事件回调。 |
| duration | number | 否 | 500 | 最小触发长按的时间,单位为毫秒(ms)。 |
## 事件
| 名称 | 功能描述 |
| -------- | -------- |
| onAction((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功,接收到触摸取消事件触发回调。 |
| 名称 | 功能描述 |
| -------- | -------- |
| onAction((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | LongPress手势识别成功,接收到触摸取消事件触发回调。 |
- GestureEvent对象中与LongPress手势相关的属性
| 属性名称 | 属性类型 | 描述 |
| 属性名称 | 属性类型 | 描述 |
| -------- | -------- | -------- |
| repeat | boolean | 事件是否为重复触发事件。 |
| repeat | boolean | 事件是否为重复触发事件。 |
## 示例
......
# PanGesture
用于触发拖动手势事件,滑动的最小距离为5vp时拖动手势识别成功。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -21,16 +23,16 @@ PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: nu
| distance | number | 否 | 5.0 | 最小滑动识别距离,单位为vp。 |
- PanDirection枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| All | 所有方向可滑动。 |
| Horizontal | 水平方向可滑动。 |
| Vertical | 竖直方向可滑动。 |
| Left | 向左滑动。 |
| Right | 向右滑动。 |
| Up | 向上滑动。 |
| Down | 向下滑动。 |
| None | 任何方向都不可滑动。 |
| All | 所有方向可滑动。 |
| Horizontal | 水平方向可滑动。 |
| Vertical | 竖直方向可滑动。 |
| Left | 向左滑动。 |
| Right | 向右滑动。 |
| Up | 向上滑动。 |
| Down | 向下滑动。 |
| None | 任何方向都不可滑动。 |
### PanGestureOptions
......@@ -43,27 +45,27 @@ PanGestureOptions(options?: { fingers?: number, direction?: PanDirection, distan
同PanGesture参数说明。
- 接口
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| setDirection(value:&nbsp;PanDirection) | 设置direction属性。 |
| setDistance(value:&nbsp;number) | 设置distance属性。 |
| setFingers(value:&nbsp;number) | 设置fingers属性。 |
| setDirection(value:&nbsp;PanDirection) | 设置direction属性。 |
| setDistance(value:&nbsp;number) | 设置distance属性。 |
| setFingers(value:&nbsp;number) | 设置fingers属性。 |
## 事件
| 名称 | 功能描述 |
| -------- | -------- |
| onActionStart(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势识别成功回调。 |
| onActionUpdate(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势移动过程中回调。 |
| onActionEnd(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势识别成功,手指抬起后触发回调。 |
| onActionCancel(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | Pan手势识别成功,接收到触摸取消事件触发回调。 |
| 名称 | 功能描述 |
| -------- | -------- |
| onActionStart(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势识别成功回调。 |
| onActionUpdate(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势移动过程中回调。 |
| onActionEnd(callback:&nbsp;(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pan手势识别成功,手指抬起后触发回调。 |
| onActionCancel(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | Pan手势识别成功,接收到触摸取消事件触发回调。 |
- GestureEvent对象中与Pan手势相关的属性
| 属性名称 | 属性类型 | 描述 |
| 属性名称 | 属性类型 | 描述 |
| -------- | -------- | -------- |
| offsetX | number | 手势事件偏移量,单位为vp。 |
| offsetY | number | 手势事件偏移量,单位为vp。 |
| offsetX | number | 手势事件偏移量,单位为vp。 |
| offsetY | number | 手势事件偏移量,单位为vp。 |
## 示例
......
# PinchGesture
用于触发捏合手势,触发捏合手势的最少手指为2指,最大为5指,最小识别距离为3vp。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -14,27 +16,27 @@
PinchGesture(options?: { fingers?: number, distance?: number })
- 参数
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| fingers | number | 否 | 2 | 触发捏合的最少手指数,&nbsp;最小为2指,最大为5指。 |
| distance | number | 否 | 3.0 | 最小识别距离,单位为vp。 |
| fingers | number | 否 | 2 | 触发捏合的最少手指数,&nbsp;最小为2指,最大为5指。 |
| distance | number | 否 | 3.0 | 最小识别距离,单位为vp。 |
## 事件
| 名称 | 功能描述 |
| -------- | -------- |
| onActionStart((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功回调。 |
| onActionUpdate((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势移动过程中回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功,接收到触摸取消事件触发回调。 |
| 名称 | 功能描述 |
| -------- | -------- |
| onActionStart((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功回调。 |
| onActionUpdate((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势移动过程中回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | Pinch手势识别成功,接收到触摸取消事件触发回调。 |
- GestureEvent对象中与Pinch手势相关的属性
| 属性名称 | 属性类型 | 描述 |
| 属性名称 | 属性类型 | 描述 |
| -------- | -------- | -------- |
| scale | number | 缩放比例,用于PinchGesture手势触发场景。 |
| pinchCenterX | number | 捏合手势中心点X轴坐标,单位为px。 |
| pinchCenterY | number | 捏合手势中心点Y轴坐标,单位为px。 |
| scale | number | 缩放比例,用于PinchGesture手势触发场景。 |
| pinchCenterX | number | 捏合手势中心点X轴坐标,单位为px。 |
| pinchCenterY | number | 捏合手势中心点Y轴坐标,单位为px。 |
## 示例
......
# RotationGesture
用于触发旋转手势事件,触发旋转手势的最少手指为2指,最大为5指,最小改变度数为1度。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -14,25 +16,25 @@
RotationGesture(options?: { fingers?: number, angle?: number })
- 参数
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| fingers | number | 否 | 2 | 触发旋转的最少手指数,&nbsp;最小为2指,最大为5指。 |
| angle | number | 否 | 1.0 | 触发旋转手势的最小改变度数,单位为度数。 |
| fingers | number | 否 | 2 | 触发旋转的最少手指数,&nbsp;最小为2指,最大为5指。 |
| angle | number | 否 | 1.0 | 触发旋转手势的最小改变度数,单位为度数。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onActionStart((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功回调。 |
| onActionUpdate((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势移动过程中回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功,接收到触摸取消事件触发回调。 |
| onActionStart((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功回调。 |
| onActionUpdate((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势移动过程中回调。 |
| onActionEnd((event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功,手指抬起后触发回调。 |
| onActionCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | Rotation手势识别成功,接收到触摸取消事件触发回调。 |
- GestureEvent对象中与Rotation手势相关的属性
| 属性名称 | 属性类型 | 描述 |
| 属性名称 | 属性类型 | 描述 |
| -------- | -------- | -------- |
| angle | number | 旋转角度。 |
| angle | number | 旋转角度。 |
## 示例
......
# SwipeGesture
用于触发滑动事件,滑动最小速度为100vp/s时识别成功。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -21,25 +23,25 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num
| speed | number | 否 | 100 | 识别滑动的最小速度(100VP/秒)。 |
- SwipeDirection枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| All | 所有方向。 |
| Horizontal | 水平方向。 |
| Vertical | 竖直方向。 |
| All | 所有方向。 |
| Horizontal | 水平方向。 |
| Vertical | 竖直方向。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onAction(callback:(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | 滑动手势识别成功回调。 |
| onAction(callback:(event?:&nbsp;GestureEvent)&nbsp;=&gt;&nbsp;void) | 滑动手势识别成功回调。 |
- GestureEvent对象中与Swipe手势相关的属性
| 参数名 | 类型 | 说明 |
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| angle | number | 滑动手势的角度,即两根手指间的线段与水平方向的夹角变化的度数。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;角度计算方式:滑动手势被识别到后,连接两根手指之间的线被识别为起始线条,随着手指的滑动,手指之间的线条会发生旋转,根据起始线条两端点和当前线条两端点的坐标,使用反正切函数分别计算其相对于水平方向的夹角,最后arctan2(cy2-cy1,cx2-cx1)-arctan2(y2-y1,x2-x1)为旋转的角度。以起始线条为坐标系,顺时针旋转为0到180度,逆时针旋转为-180到0度。 |
| speed | number | 滑动手势的速度,是所有手指滑动的平均速度,单位为VP/秒。 |
| angle | number | 滑动手势的角度,即两根手指间的线段与水平方向的夹角变化的度数。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;角度计算方式:滑动手势被识别到后,连接两根手指之间的线被识别为起始线条,随着手指的滑动,手指之间的线条会发生旋转,根据起始线条两端点和当前线条两端点的坐标,使用反正切函数分别计算其相对于水平方向的夹角,最后arctan2(cy2-cy1,cx2-cx1)-arctan2(y2-y1,x2-x1)为旋转的角度。以起始线条为坐标系,顺时针旋转为0到180度,逆时针旋转为-180到0度。 |
| speed | number | 滑动手势的速度,是所有手指滑动的平均速度,单位为VP/秒。 |
![zh-cn_image_0000001231374559](figures/zh-cn_image_0000001231374661.png)
## 示例
......
# TapGesture
支持单次点击、多次点击识别。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -14,17 +16,17 @@
TapGesture(options?: { count?: number, fingers?: number })
- 参数
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| count | number | 否 | 1 | 识别的连续点击次数。如果设置小于1,会被转化为默认值。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;如配置多击,上一次抬起和下一次按下的超时时间为300毫秒(ms)。 |
| fingers | number | 否 | 1 | 触发点击的最少手指数,最小为1指,&nbsp;最大为10指。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;1.&nbsp;当配置多指时,第一根手指按下后300毫秒(ms)内未有足够的手指数按下,手势识别失败。<br/>>&nbsp;<br/>>&nbsp;2.&nbsp;实际点击手指数超过配置值,手势识别失败。 |
| count | number | 否 | 1 | 识别的连续点击次数。如果设置小于1,会被转化为默认值。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;如配置多击,上一次抬起和下一次按下的超时时间为300毫秒(ms)。 |
| fingers | number | 否 | 1 | 触发点击的最少手指数,最小为1指,&nbsp;最大为10指。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;1.&nbsp;当配置多指时,第一根手指按下后300毫秒(ms)内未有足够的手指数按下,手势识别失败。<br/>>&nbsp;<br/>>&nbsp;2.&nbsp;实际点击手指数超过配置值,手势识别失败。 |
## 事件
| 名称 | 功能描述 |
| -------- | -------- |
| onAction((event?:&nbsp;[GestureEvent](ts-gesture-settings.md))&nbsp;=&gt;&nbsp;void) | Tap手势识别成功回调。 |
| 名称 | 功能描述 |
| -------- | -------- |
| onAction((event?:&nbsp;[GestureEvent](ts-gesture-settings.md))&nbsp;=&gt;&nbsp;void) | Tap手势识别成功回调。 |
## 示例
......
# 组合手势
手势识别组,多种手势组合为复合手势,支持连续识别、并行识别和互斥识别。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -20,18 +22,18 @@ GestureGroup(mode: GestureMode, ...gesture: GestureType[])
| gesture | [TapGesture](ts-basic-gestures-tapgesture.md)<br/>\|&nbsp;[LongPressGesture](ts-basic-gestures-longpressgesture.md)<br/>\|&nbsp;[PanGesture](ts-basic-gestures-pangesture.md)<br/>\|&nbsp;[PinchGesture](ts-basic-gestures-pinchgesture.md)<br/>\|&nbsp;[RotationGesture](ts-basic-gestures-rotationgesture.md) | 是 | - | 可变长参数,1个或者多个基础手势类型,这些手势会被组合识别。 |
- GestureMode枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Sequence | 顺序识别,按照手势的注册顺序识别手势,直到所有手势识别成功。当有一个手势识别失败时,所有手势识别失败。 |
| Parallel | 并发识别,注册的手势同时识别,直到所有手势识别结束,手势识别互相不影响。 |
| Exclusive | 互斥识别,注册的手势同时识别,若有一个手势识别成功,则结束手势识别。 |
| Sequence | 顺序识别,按照手势的注册顺序识别手势,直到所有手势识别成功。当有一个手势识别失败时,所有手势识别失败。 |
| Parallel | 并发识别,注册的手势同时识别,直到所有手势识别结束,手势识别互相不影响。 |
| Exclusive | 互斥识别,注册的手势同时识别,若有一个手势识别成功,则结束手势识别。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 顺序组合手势(GestureMode.Sequence)取消后触发回调。 |
| onCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 顺序组合手势(GestureMode.Sequence)取消后触发回调。 |
## 示例
......
# Lottie
提供Lottie动画。
> **说明:**
> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# AlphabetIndexer
可以与容器组件联动用于按逻辑结构快速定位容器显示区域的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
字母索引条。
## 权限列表
......@@ -23,32 +20,32 @@
AlphabetIndexer(value: {arrayValue : Array&lt;string&gt;, selected : number})
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| arrayValue | Array&lt;string&gt; | 是 | - | 字母索引字符串数组。 |
| selected | number | 是 | - | 选中项编号。 |
| arrayValue | Array&lt;string&gt; | 是 | - | 字母索引字符串数组。 |
| selected | number | 是 | - | 选中项编号。 |
## 属性
| 名称 | 参数类型 | 描述 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| selectedColor | Color | 选中文本文字颜色。 |
| popupColor | Color | 弹出提示文本字体颜色。 |
| selectedBackgroundColor | Color | 选中文本背景颜色。 |
| popupBackground | Color | 弹窗索引背景色。 |
| usingPopup | boolean | 是否使用弹出索引提示。 |
| selectedFont | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 选中文本文字样式。 |
| popupFont | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 弹出提示文本字体样式。 |
| font | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 字母索引条默认文本字体样式。 |
| itemSize | Length | 字母索引条字母区域大小,字母区域为正方形,设置正方形边长。 |
| alignStyle | IndexerAlign | 字母索引条对齐样式,支持左侧对齐样式与右侧对齐样式,影响弹窗弹出位置。 |
| selectedColor | Color | 选中文本文字颜色。 |
| popupColor | Color | 弹出提示文本字体颜色。 |
| selectedBackgroundColor | Color | 选中文本背景颜色。 |
| popupBackground | Color | 弹窗索引背景色。 |
| usingPopup | boolean | 是否使用弹出索引提示。 |
| selectedFont | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 选中文本文字样式。 |
| popupFont | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 弹出提示文本字体样式。 |
| font | {<br/>size?:&nbsp;number,<br/>weight?:&nbsp;FontWeight,<br/>family?:&nbsp;string,<br/>style?:&nbsp;FontStyle<br/>} | 字母索引条默认文本字体样式。 |
| itemSize | Length | 字母索引条字母区域大小,字母区域为正方形,设置正方形边长。 |
| alignStyle | IndexerAlign | 字母索引条对齐样式,支持左侧对齐样式与右侧对齐样式,影响弹窗弹出位置。 |
- IndexerAlign枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Left | 弹框显示在索引条右侧。 |
| Right | 弹框显示在索引条左侧。 |
| Left | 弹框显示在索引条右侧。 |
| Right | 弹框显示在索引条左侧。 |
## 事件
......
# Badge
可以附加在单个组件上用于信息标记的容器组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
新事件标记组件,在组件上提供事件信息展示能力。
## 权限列表
......@@ -49,11 +48,11 @@ Badge(value: {value: string, position?: BadgePosition, style?: BadgeStyle})
| badgeColor | Color | 否 | Color.Red | badge的颜色。 |
- BadgePosition枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Right | 圆点显示在右侧纵向居中。 |
| RightTop | 圆点显示在右上角。 |
| Left | 圆点显示在左侧纵向居中。 |
| Right | 圆点显示在右侧纵向居中。 |
| RightTop | 圆点显示在右上角。 |
| Left | 圆点显示在左侧纵向居中。 |
## 示例
......
# Flex
应用弹性方式布局子组件的容器组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
弹性布局组件。
## 权限列表
......
# Refresh
可以进行页面下拉操作并显示刷新动效的容器组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
下拉刷新容器。
## 权限列表
......
# Circle
用于绘制圆形的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
圆形绘制组件。
## 权限列表
......@@ -27,18 +26,18 @@ Circle(options?: {width: Length, height: Length})
| options | Object | 否 | - | 见options参数说明。 |
- options参数说明
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| width | Length | 是 | - | 宽度。 |
| height | Length | 是 | - | 高度。 |
| width | Length | 是 | - | 宽度。 |
| height | Length | 是 | - | 高度。 |
## 属性
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| width | Length | 0 | 否 | 圆所在矩形的宽度。 |
| height | Length | 0 | 否 | 圆所在矩形的高度。 |
| width | Length | 0 | 否 | 圆所在矩形的宽度。 |
| height | Length | 0 | 否 | 圆所在矩形的高度。 |
## 示例
......
# 显式动画
提供显示动画接口。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -12,20 +14,20 @@
## AnimationOptions对象说明
- 属性
| 属性名称 | 属性类型 | 默认值 | 描述 |
| 属性名称 | 属性类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| duration | number | 1000 | 动画持续时间,单位为毫秒。 |
| tempo | number | 1.0 | 动画的播放速度,值越大动画播放越快,值越小播放越慢,为0时无动画效果。 |
| curve | Curve&nbsp;\|&nbsp;Curves | Linear | 动画曲线。 |
| delay | number | 0 | 单位为ms(毫秒),默认不延时播放。 |
| iterations | number | 1 | 默认播放一次,设置为-1时表示无限次播放。 |
| playMode | PlayMode | Normal | 设置动画播放模式,默认播放完成后重头开始播放。 |
| duration | number | 1000 | 动画持续时间,单位为毫秒。 |
| tempo | number | 1.0 | 动画的播放速度,值越大动画播放越快,值越小播放越慢,为0时无动画效果。 |
| curve | Curve&nbsp;\|&nbsp;Curves | Linear | 动画曲线。 |
| delay | number | 0 | 单位为ms(毫秒),默认不延时播放。 |
| iterations | number | 1 | 默认播放一次,设置为-1时表示无限次播放。 |
| playMode | PlayMode | Normal | 设置动画播放模式,默认播放完成后重头开始播放。 |
- 接口
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onFinish()&nbsp;=&gt;&nbsp;void | 动效播放完成回调。 |
| onFinish()&nbsp;=&gt;&nbsp;void | 动效播放完成回调。 |
## 示例
......
# 绑定手势方法
为组件绑定不同类型的手势事件,并设置事件的响应方法。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 插值计算
设置动画插值曲线,用于构造阶梯曲线对象、构造三阶贝塞尔曲线对象和构造弹簧曲线对象。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -48,10 +50,10 @@ stepsCurve(count: number, end: boolean):ICurve
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | 是 | 阶梯的数量,需要为正整数。 |
| end | boolean | 是 | 在每个间隔的起点或是终点发生阶跃变化。<br>-true:在终点发生阶跃变化。<br>-false:在起点发生阶跃变化。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | 是 | 阶梯的数量,需要为正整数。 |
| end | boolean | 是 | 在每个间隔的起点或是终点发生阶跃变化。<br>-true:在终点发生阶跃变化。<br>-false:在起点发生阶跃变化。 |
**返回值:**
......@@ -77,12 +79,12 @@ cubicBezierCurve(x1: number, y1: number, x2: number, y2: number):ICurve
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | -------------- |
| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。 |
| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。 |
| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。 |
| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | -------------- |
| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。 |
| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。 |
| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。 |
| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。 |
**返回值:**
......@@ -185,10 +187,10 @@ steps(count: number, end: boolean): string
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | 是 | 阶梯的数量,需要为正整数。 |
| end | boolean | 是 | 在每个间隔的起点或是终点发生阶跃变化。<br>-true:在终点发生阶跃变化。<br>-false:在起点发生阶跃变化。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | 是 | 阶梯的数量,需要为正整数。 |
| end | boolean | 是 | 在每个间隔的起点或是终点发生阶跃变化。<br>-true:在终点发生阶跃变化。<br>-false:在起点发生阶跃变化。 |
## Curves.cubicBezier<sup>(deprecated)</sup>
......@@ -200,12 +202,12 @@ cubicBezier(x1: number, y1: number, x2: number, y2: number): string
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | -------------- |
| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。 |
| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。 |
| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。 |
| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | -------------- |
| x1 | number | 是 | 确定贝塞尔曲线第一点横坐标。 |
| y1 | number | 是 | 确定贝塞尔曲线第一点纵坐标。 |
| x2 | number | 是 | 确定贝塞尔曲线第二点横坐标。 |
| y2 | number | 是 | 确定贝塞尔曲线第二点纵坐标。 |
## Curves.spring<sup>(deprecated)</sup>
......@@ -227,21 +229,21 @@ spring(velocity: number, mass: number, stiffness: number, damping: number): stri
## Curve枚举说明
| 名称 | 描述 |
| ------------------- | ---------------------------------------- |
| Linear | 表示动画从头到尾的速度都是相同的。 |
| Ease | 表示动画以低速开始,然后加快,在结束前变慢,CubicBezier(0.25,&nbsp;0.1,&nbsp;0.25,&nbsp;1.0)。 |
| EaseIn | 表示动画以低速开始,CubicBezier(0.42,&nbsp;0.0,&nbsp;1.0,&nbsp;1.0)。 |
| EaseOut | 表示动画以低速结束,CubicBezier(0.0,&nbsp;0.0,&nbsp;0.58,&nbsp;1.0)。 |
| EaseInOut | 表示动画以低速开始和结束,CubicBezier(0.42,&nbsp;0.0,&nbsp;0.58,&nbsp;1.0)。 |
| FastOutSlowIn | 标准曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| LinearOutSlowIn | 减速曲线,cubic-bezier(0.0,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| FastOutLinearIn | 加速曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;1.0,&nbsp;1.0)。 |
| ExtremeDeceleration | 急缓曲线,cubic-bezier(0.0,&nbsp;0.0,&nbsp;0.0,&nbsp;1.0)。 |
| Sharp | 锐利曲线,cubic-bezier(0.33,&nbsp;0.0,&nbsp;0.67,&nbsp;1.0)。 |
| Rhythm | 节奏曲线,cubic-bezier(0.7,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| Smooth | 平滑曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;0.4,&nbsp;1.0)。 |
| Friction | 阻尼曲线,CubicBezier(0.2,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| 名称 | 描述 |
| ------------------- | ---------------------------------------- |
| Linear | 表示动画从头到尾的速度都是相同的。 |
| Ease | 表示动画以低速开始,然后加快,在结束前变慢,CubicBezier(0.25,&nbsp;0.1,&nbsp;0.25,&nbsp;1.0)。 |
| EaseIn | 表示动画以低速开始,CubicBezier(0.42,&nbsp;0.0,&nbsp;1.0,&nbsp;1.0)。 |
| EaseOut | 表示动画以低速结束,CubicBezier(0.0,&nbsp;0.0,&nbsp;0.58,&nbsp;1.0)。 |
| EaseInOut | 表示动画以低速开始和结束,CubicBezier(0.42,&nbsp;0.0,&nbsp;0.58,&nbsp;1.0)。 |
| FastOutSlowIn | 标准曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| LinearOutSlowIn | 减速曲线,cubic-bezier(0.0,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| FastOutLinearIn | 加速曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;1.0,&nbsp;1.0)。 |
| ExtremeDeceleration | 急缓曲线,cubic-bezier(0.0,&nbsp;0.0,&nbsp;0.0,&nbsp;1.0)。 |
| Sharp | 锐利曲线,cubic-bezier(0.33,&nbsp;0.0,&nbsp;0.67,&nbsp;1.0)。 |
| Rhythm | 节奏曲线,cubic-bezier(0.7,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
| Smooth | 平滑曲线,cubic-bezier(0.4,&nbsp;0.0,&nbsp;0.4,&nbsp;1.0)。 |
| Friction | 阻尼曲线,CubicBezier(0.2,&nbsp;0.0,&nbsp;0.2,&nbsp;1.0)。 |
## 整体示例
......
# 矩阵变换
可对图形进行平移、旋转和缩放等。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# Video
用于播放单个视频并控制其播放状态的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
视频播放组件。
## 权限列表
使用网络视频时,需要在config或者module.json对应的"abilities"中添加网络使用权限ohos.permission.INTERNET。
......
# 菜单
在页面范围内关闭通过[bindContextMenu](./ts-universal-attributes-menu.md#属性)属性绑定的菜单。
> **说明:**
> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 点击控制
设置组件是否可触摸。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
......@@ -13,9 +13,9 @@ id为组件的唯一标识,在整个应用内唯一。本模块提供组件标
## 属性
| 名称 | 参数说明 | 默认值 | 描述 |
| 名称 | 参数说明 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| id | string | '' | 组件的唯一标识,唯一性由使用者保证。 |
| id | string | '' | 组件的唯一标识,唯一性由使用者保证。 |
## 接口
......@@ -28,14 +28,14 @@ getInspectorByKey(id: string): string
获取指定id的组件的所有属性,不包括子组件信息。
- 参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
| 参数 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| id | string | 是 | - | 要获取属性的组件id。 |
| id | string | 是 | - | 要获取属性的组件id。 |
- 返回值
| 类型 | 描述 |
| 类型 | 描述 |
| -------- | -------- |
| string | 组件属性列表的JSON字符串。 |
| string | 组件属性列表的JSON字符串。 |
### getInspectorTree
......@@ -56,16 +56,16 @@ sendEventByKey(id: string, action: number, params: string): boolean
给指定id的组件发送事件。
- 参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
| 参数 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| id | string | 是 | - | 要触发事件的组件的id。 |
| action | number | 是 | - | 要触发的事件类型,目前支持取值:<br/>-&nbsp;点击事件Click:&nbsp;10<br/>-&nbsp;长按事件LongClick:&nbsp;11。 |
| params | string | 是 | - | 事件参数,无参数传空字符串&nbsp;""。 |
| id | string | 是 | - | 要触发事件的组件的id。 |
| action | number | 是 | - | 要触发的事件类型,目前支持取值:<br/>-&nbsp;点击事件Click:&nbsp;10<br/>-&nbsp;长按事件LongClick:&nbsp;11。 |
| params | string | 是 | - | 事件参数,无参数传空字符串&nbsp;""。 |
- 返回值
| 类型 | 描述 |
| 类型 | 描述 |
| -------- | -------- |
| boolean | 找不到指定id的组件时返回false,其余情况返回true。 |
| boolean | 找不到指定id的组件时返回false,其余情况返回true。 |
### sendTouchEvent
......
# 禁用控制
可交互状态下组件响应点击事件。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -12,9 +14,9 @@
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| enabled | boolean | true | 值为true表示组件可用,可响应点击等操作;值为false时,不响应点击等操作。 |
| enabled | boolean | true | 值为true表示组件可用,可响应点击等操作;值为false时,不响应点击等操作。 |
## 示例
......
# 焦点控制
自定义组件的走焦效果,可设置组件是否走焦和具体的走焦顺序,tab键或者方向键切换焦点。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -11,9 +13,9 @@
## 属性
| **名称** | **参数类型** | **默认值** | **描述** |
| **名称** | **参数类型** | **默认值** | **描述** |
| -------- | -------- | -------- | -------- |
| focusable | boolean | false | 设置当前组件是否可以获焦。 |
| focusable | boolean | false | 设置当前组件是否可以获焦。 |
| tabIndex<sup>9+<sup> | number | 0 | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。<br />- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,按照tabIndex的数值递增而先后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦<br />- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素 |
> **说明:**
......
# 颜色渐变
设置组件的颜色渐变效果。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -22,17 +24,17 @@
- GradientDirection枚举说明<br>
GradientDirection用于描述渐变方向。
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Left | 从右向左。 |
| Top | 从下向上。 |
| Right | 从左向右。 |
| Bottom | 从上向下。 |
| LeftTop | 左上。 |
| LeftBottom | 左下。 |
| RightTop | 右上。 |
| RightBottom | 右下。 |
| None | 无。 |
| Left | 从右向左。 |
| Top | 从下向上。 |
| Right | 从左向右。 |
| Bottom | 从上向下。 |
| LeftTop | 左上。 |
| LeftBottom | 左下。 |
| RightTop | 右上。 |
| RightBottom | 右下。 |
| None | 无。 |
## 示例
......
# 悬浮态效果
设置组件的鼠标悬浮态显示效果。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 图像效果
例如背景模糊、内容模糊和灰度效果等。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 布局约束
通过组件的宽高比和显示优先级约束组件显示效果。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -12,10 +14,10 @@
## 属性
| 名称 | 参数说明 | 默认值 | 描述 |
| 名称 | 参数说明 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| aspectRatio | number | - | 指定当前组件的宽高比。 |
| displayPriority | number | - | 设置当前组件在布局容器中显示的优先级,当父容器空间不足时,低优先级的组件会被隐藏。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;仅在Row/Column/Flex(单行)容器组件中生效。 |
| aspectRatio | number | - | 指定当前组件的宽高比。 |
| displayPriority | number | - | 设置当前组件在布局容器中显示的优先级,当父容器空间不足时,低优先级的组件会被隐藏。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;仅在Row/Column/Flex(单行)容器组件中生效。 |
## 示例
......
# 位置设置
设置组件的对齐方式、布局方向和显示位置。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -22,11 +24,11 @@
- Direction枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Ltr | 元素从左到右布局。 |
| Rtl | 元素从右到左布局。 |
| Auto | 使用系统默认布局方向。 |
| Ltr | 元素从左到右布局。 |
| Rtl | 元素从右到左布局。 |
| Auto | 使用系统默认布局方向。 |
## 示例
......
# Menu控制
为组件绑定弹出式菜单,弹出式菜单以垂直列表形式显示菜单项,可通过长按、点击或鼠标右键触发。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 浮层
设置组件的遮罩文本。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# Popup控制
设置组件点击时弹出的气泡框状态。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -18,13 +20,13 @@
- PopupOptions类型接口说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
| 名称 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| message | string | 是 | - | 弹窗信息内容。 |
| placementOnTop | boolean | 否 | false | 是否在组件上方显示,默认值为false。 |
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 |
| secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 |
| onStateChange | (isVisible:&nbsp;boolean)&nbsp;=&gt;&nbsp;void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
| message | string | 是 | - | 弹窗信息内容。 |
| placementOnTop | boolean | 否 | false | 是否在组件上方显示,默认值为false。 |
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 |
| secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 |
| onStateChange | (isVisible:&nbsp;boolean)&nbsp;=&gt;&nbsp;void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
- CustomPopupOptions<sup>8+</sup>类型接口说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
......
# 形状裁剪
用于对组件进行裁剪、遮罩处理。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -12,10 +14,10 @@
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| clip | Shape&nbsp;\|&nbsp;boolean | false | 参数为Shape类型时,按指定的形状对当前组件进行裁剪;参数为boolean类型时,设置是否按照边缘轮廓进行裁剪。 |
| mask | Shape | - | 在当前组件上加上指定形状的遮罩。 |
| clip | Shape&nbsp;\|&nbsp;boolean | false | 参数为Shape类型时,按指定的形状对当前组件进行裁剪;参数为boolean类型时,设置是否按照边缘轮廓进行裁剪。 |
| mask | Shape | - | 在当前组件上加上指定形状的遮罩。 |
## 示例
......
# 尺寸设置
用于设置组件的宽高、边距等显示尺寸进行设置。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 图形变换
用于对组件进行旋转、平移、缩放、矩阵变换等操作。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 显隐控制
控制组件是否可见。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -18,11 +20,11 @@
- Visibility枚举说明
| 名称 | 描述 |
| 名称 | 描述 |
| -------- | -------- |
| Hidden | 隐藏,但参与布局进行占位。 |
| Visible | 显示。 |
| None | 隐藏,但不参与布局,不进行占位。 |
| Hidden | 隐藏,但参与布局进行占位。 |
| Visible | 显示。 |
| None | 隐藏,但不参与布局,不进行占位。 |
## 示例
......
# Z序控制
组件的Z序,指明了该组件在堆叠组件中的位置。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -12,9 +14,9 @@
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| zIndex | number | 0 | 同一容器中兄弟组件显示层级关系,z值越大,显示层级越高。 |
| zIndex | number | 0 | 同一容器中兄弟组件显示层级关系,z值越大,显示层级越高。 |
## 示例
......
# 组件区域变化事件
组件区域变化事件指组件显示的尺寸、位置等发生变化时触发的事件。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -11,9 +13,9 @@
## 事件
| 名称 | 支持冒泡 | 功能描述 |
| -------- | -------- | -------- |
| onAreaChange(event:&nbsp;(oldValue:&nbsp;Area,&nbsp;newValue:&nbsp;Area)&nbsp;=&gt;&nbsp;void) | 否 | 组件区域变化时触发该回调,Area类型说明见[Area对象](ts-universal-events-click.md)介绍。 |
| 名称 | 支持冒泡 | 功能描述 |
| -------- | -------- | -------- |
| onAreaChange(event:&nbsp;(oldValue:&nbsp;Area,&nbsp;newValue:&nbsp;Area)&nbsp;=&gt;&nbsp;void) | 否 | 组件区域变化时触发该回调,Area类型说明见[Area对象](ts-universal-events-click.md)介绍。 |
## 示例
......
# 点击事件
点击事件指组件被点击时触发的事件。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 支持设备
| 手机 | 平板 | 智慧屏 | 智能穿戴 |
| ---- | ---- | ------ | -------- |
| 支持 | 支持 | 不支持 | 不支持 |
## 权限列表
......
# 拖拽事件
拖拽事件指被长按后拖拽时触发的事件。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 按键事件
按键事件指组件与键盘、遥控器等按键设备交互时触发的事件。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 挂载卸载事件
挂载卸载事件指组件从组件树上挂载、卸载时触发的事件。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 触摸事件
当手指放在组件上、滑动或从组件上移开时触发。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
# 焦点事件
焦点事件指页面焦点在组件间移动时触发的事件,组件可使用焦点事件来更改内容。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......@@ -11,10 +13,10 @@
## 事件
| **名称** | **支持冒泡** | **功能描述** |
| **名称** | **支持冒泡** | **功能描述** |
| -------- | -------- | -------- |
| onFocus(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 否 | 当前组件获取焦点时触发的回调。 |
| onBlur(callback:()&nbsp;=&gt;&nbsp;void) | 否 | 当前组件失去焦点时触发的回调。 |
| onFocus(callback:&nbsp;()&nbsp;=&gt;&nbsp;void) | 否 | 当前组件获取焦点时触发的回调。 |
| onBlur(callback:()&nbsp;=&gt;&nbsp;void) | 否 | 当前组件失去焦点时触发的回调。 |
> **说明:**
> 支持焦点事件的组件:Button、Text、Image、List、Grid。
......
# 鼠标事件
在单个动作触发多个事件时,事件的顺序是固定的,遵循xxx的顺序调用处理程序。
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册