提交 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
......
......@@ -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 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
......
# 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/> } |
......
# Lottie
提供Lottie动画。
> **说明:**
> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册