提交 3cee84e4 编写于 作者: L luoying_ace 提交者: Gitee

Merge branch 'OpenHarmony-3.1-Release' of gitee.com:openharmony/docs into ly810

Signed-off-by: Nluoying_ace <luoying19@huawei.com>
......@@ -6,22 +6,20 @@ The Distributed Data Service (DDS) implements synchronization of application dat
## Available APIs
For details about the APIs related to distributed data, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md).
The table below describes the APIs provided by the OpenHarmony DDS module.
**Table 1** APIs provided by the DDS
| Category | API | Description |
| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------- |
| Creating a distributed database | createKVManager(config:&nbsp;KVManagerConfig,&nbsp;callback:&nbsp;AsyncCallback&lt;KVManager&gt;):&nbsp;void<br>createKVManager(config:&nbsp;KVManagerConfig):&nbsp;Promise&lt;KVManager> | Creates a **KVManager** object for database management.|
| Obtaining a distributed KV store | getKVStore&lt;T&nbsp;extends&nbsp;KVStore&gt;(storeId:&nbsp;string,&nbsp;options:&nbsp;Options,&nbsp;callback:&nbsp;AsyncCallback&lt;T&gt;):&nbsp;void<br>getKVStore&lt;T&nbsp;extends&nbsp;KVStore&gt;(storeId:&nbsp;string,&nbsp;options:&nbsp;Options):&nbsp;Promise&lt;T&gt; | Obtains the KV store with the specified **Options** and **storeId**.|
| Managing data in a distributed KV store| put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void<br>put(key:&nbsp;string,&nbsp;value:&nbsp;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;boolean):&nbsp;Promise&lt;void> | Inserts and updates data. |
| Managing data in a distributed KV store| delete(key:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void<br>delete(key:&nbsp;string):&nbsp;Promise&lt;void> | Deletes data. |
| Managing data in a distributed KV store| get(key:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;boolean&nbsp;\|&nbsp;number&gt;):&nbsp;void<br>get(key:&nbsp;string):&nbsp;Promise&lt;Uint8Array&nbsp;\|&nbsp;string&nbsp;\|&nbsp;boolean&nbsp;\|&nbsp;number> | Queries data. |
| Subscribing to changes in the distributed data | on(event:&nbsp;'dataChange',&nbsp;type:&nbsp;SubscribeType,&nbsp;observer:&nbsp;Callback&lt;ChangeNotification&gt;):&nbsp;void<br>on(event:&nbsp;'syncComplete',&nbsp;syncCallback:&nbsp;Callback&lt;Array&lt;[string,&nbsp;number]&gt;&gt;):&nbsp;void | Subscribes to data changes in the KV store. |
| Synchronizing data across devices | sync(deviceIdList:&nbsp;string[],&nbsp;mode:&nbsp;SyncMode,&nbsp;allowedDelayMs?:&nbsp;number):&nbsp;void | Triggers database synchronization in manual mode. |
| API | Description |
| ------------------------------------------------------------ | ----------------------------------------------- |
| createKVManager(config:KVManagerConfig,callback:AsyncCallback&lt;KVManager&gt;):void<br>createKVManager(config:KVManagerConfig):Promise&lt;KVManager> | Creates a **KVManager** object for database management.|
| getKVStore&lt;TextendsKVStore&gt;(storeId:string,options:Options,callback:AsyncCallback&lt;T&gt;):void<br>getKVStore&lt;TextendsKVStore&gt;(storeId:string,options:Options):Promise&lt;T&gt; | Obtains a KV store with the specified **Options** and **storeId**.|
| put(key:string,value:Uint8Array\|string\|number\|boolean,callback:AsyncCallback&lt;void&gt;):void<br>put(key:string,value:Uint8Array\|string\|number\|boolean):Promise&lt;void> | Inserts and updates data. |
| delete(key:string,callback:AsyncCallback&lt;void&gt;):void<br>delete(key:string):Promise&lt;void> | Deletes data. |
| get(key:string,callback:AsyncCallback&lt;Uint8Array\|string\|boolean\|number&gt;):void<br>get(key:string):Promise&lt;Uint8Array\|string\|boolean\|number> | Queries data. |
| on(event:'dataChange',type:SubscribeType,observer:Callback&lt;ChangeNotification&gt;):void<br>on(event:'syncComplete',syncCallback:Callback&lt;Array&lt;[string,number]&gt;&gt;):void | Subscribes to data changes in the KV store. |
| sync(deviceIdList:string[],mode:SyncMode,allowedDelayMs?:number):void | Triggers database synchronization in manual mode. |
......@@ -36,11 +34,14 @@ The following uses a single KV store as an example to describe the development p
```
2. Create a **KvManager** instance based on the specified **KvManagerConfig** object.
1. Create a **KvManagerConfig** object based on the application context.
2. Create a **KvManager** instance.
(1) Create a **KvManagerConfig** object based on the application context.
(2) Create a **KvManager** instance.
The sample code is as follows:
```js
```
let kvManager;
try {
const kvManagerConfig = {
......@@ -63,9 +64,12 @@ The following uses a single KV store as an example to describe the development p
}
```
3. Create and obtain a single KV store.
1. Declare the ID of the single KV store to create.
2. Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required.
(1) Declare the ID of the single KV store to create.
(2) Create a single KV store. You are advised to disable automatic synchronization (**autoSync:false**) and call **sync** when a synchronization is required.
The sample code is as follows:
```js
......@@ -92,8 +96,9 @@ The following uses a single KV store as an example to describe the development p
}
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (**kvStore** in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle.
> **NOTE**
>
> For data synchronization between networked devices, you are advised to open the distributed KV store during application startup to obtain the database handle. With this database handle (`kvStore` in this example), you can perform operations, such as inserting data into the KV store, without creating the KV store repeatedly during the lifecycle of the handle.
4. Subscribe to changes in the distributed data.<br/>
The following is the sample code for subscribing to the data changes of a single KV store:
......@@ -104,8 +109,10 @@ The following uses a single KV store as an example to describe the development p
```
5. Write data to the single KV store.
1. Construct the key and value to be written into the single KV store.
2. Write key-value pairs into the single KV store.
(1) Construct the key and value to be written into the single KV store.
(2) Write key-value pairs into the single KV store.
The following is the sample code for writing key-value pairs of the string type into the single KV store:
......@@ -126,8 +133,10 @@ The following uses a single KV store as an example to describe the development p
```
6. Query data in the single KV store.
1. Construct the key to be queried from the single KV store.
2. Query data from the single KV store.
(1) Construct the key to be queried from the single KV store.
(2) Query data from the single KV store.
The following is the sample code for querying data of the string type from the single KV store:
```js
......@@ -152,7 +161,11 @@ The following uses a single KV store as an example to describe the development p
7. Synchronize data to other devices.<br/>
Select the devices in the same network and the synchronization mode to synchronize data.
The following is the sample code for data synchronization in a single KV store. **deviceIds** can be obtained by deviceManager by calling **getTrustedDeviceListSync()**, and **1000** indicates that the maximum delay time is 1000 ms.
> **NOTE**
>
> The APIs of the `deviceManager` module are system interfaces.
The following is the sample code for synchronizing data in a single KV store:
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
......@@ -161,7 +174,7 @@ The following uses a single KV store as an example to describe the development p
deviceManager.createDeviceManager("bundleName", (err, value) => {
if (!err) {
devManager = value;
// Obtain deviceIds.
// deviceIds is obtained by deviceManager by calling getTrustedDeviceListSync().
let deviceIds = [];
if (devManager != null) {
var devices = devManager.getTrustedDeviceListSync();
......@@ -170,6 +183,7 @@ The following uses a single KV store as an example to describe the development p
}
}
try{
// 1000 indicates that the maximum delay is 1000 ms.
kvStore.sync(deviceIds, distributedData.SyncMode.PUSH_ONLY, 1000);
}catch (e) {
console.log("An unexpected error occurred. Error:" + e);
......@@ -177,7 +191,3 @@ The following uses a single KV store as an example to describe the development p
}
});
```
## Samples
The following samples are provided to help you better understand the distributed data development:
- [`KvStore`: Distributed Database (eTS) (API8)](https://gitee.com/openharmony/app_samples/tree/master/data/Kvstore)
- [Distributed Database](https://gitee.com/openharmony/codelabs/tree/master/Data/JsDistributedData)
......@@ -76,8 +76,8 @@ Use the following APIs to delete a **Storage** instance or data file.
1. Import **@ohos.data.storage** and related modules to the development environment.
```js
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility' // Used to obtain the file storage path.
import dataStorage from '@ohos.data.storage';
import featureAbility from '@ohos.ability.featureAbility'; // Used to obtain the file storage path.
```
2. Create a **Storage** instance.
......@@ -85,9 +85,14 @@ Use the following APIs to delete a **Storage** instance or data file.
Read the specified file and load its data to the **Storage** instance for data operations.
```js
var context = featureAbility.getContext()
var path = await context.getFilesDir()
let promise = dataStorage.getStorage(path + '/mystore')
var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
});
let promise = dataStorage.getStorage(path + '/mystore');
```
......@@ -97,14 +102,14 @@ Use the following APIs to delete a **Storage** instance or data file.
```js
promise.then((storage) => {
let getPromise = storage.put('startup', 'auto') // Save data to the Storage instance.
let getPromise = storage.put('startup', 'auto'); // Save data to the Storage instance.
getPromise.then(() => {
console.info("Put the value of startup successfully.")
console.info("Succeeded in putting the value of startup.");
}).catch((err) => {
console.info("Put the value of startup failed with err: " + err)
console.info("Failed to put the value of startup with err: " + err);
})
}).catch((err) => {
console.info("Get the storage failed")
console.info("Failed to get the storage.");
})
```
......@@ -115,14 +120,14 @@ Use the following APIs to delete a **Storage** instance or data file.
```js
promise.then((storage) => {
let getPromise = storage.get('startup', 'default')
let getPromise = storage.get('startup', 'default');
getPromise.then((value) => {
console.info("The value of startup is " + value)
console.info("The value of startup is " + value);
}).catch((err) => {
console.info("Get the value of startup failed with err: " + err)
console.info("Failed to get the value of startup with err: " + err);
})
}).catch((err) => {
console.info("Get the storage failed")
console.info("Failed to get the storage.");
})
```
......@@ -142,15 +147,15 @@ Use the following APIs to delete a **Storage** instance or data file.
```js
promise.then((storage) => {
var observer = function (key) {
console.info("The key of " + key + " changed.")
console.info("The key of " + key + " changed.");
}
storage.on('change', observer)
storage.putSync('startup', 'auto') // Modify data in the Storage instance.
storage.flushSync() // Trigger the StorageObserver callback.
storage.on('change', observer);
storage.putSync('startup', 'auto'); // Modify data in the Storage instance.
storage.flushSync(); // Trigger the StorageObserver callback.
storage.off(...change..., observer) // Unsubscribe from the data changes.
storage.off('change', observer); // Unsubscribe from the data changes.
}).catch((err) => {
console.info("Get the storage failed")
console.info("Failed to get the storage.");
})
```
......@@ -160,11 +165,11 @@ Use the following APIs to delete a **Storage** instance or data file.
Use the **deleteStorage** method to delete the **Storage** singleton of the specified file from the memory, and delete the specified file, its backup file, and damaged files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will occur. The deleted data and files cannot be restored.
```js
let promise = dataStorage.deleteStorage(path + '/mystore')
let promise = dataStorage.deleteStorage(path + '/mystore');
promise.then(() => {
console.info("Deleted successfully.")
console.info("Succeeded in deleting the storage.");
}).catch((err) => {
console.info("Deleted failed with err: " + err)
console.info("Failed to deleted the storage with err: " + err);
})
```
# Performance Tracing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**
> - The APIs of this module are no longer maintained since API version 8. It is recommended that you use the APIs of [hiTraceMeter](js-apis-hitracemeter.md) instead.
> - 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.
## Modules to Import
```
```js
import bytrace from '@ohos.bytrace';
```
......@@ -17,7 +17,11 @@ import bytrace from '@ohos.bytrace';
startTrace(name: string, taskId: number, expectedTime?: number): void
Starts a trace task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace.
Marks the start of a timeslice trace task.
> **NOTE**
>
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**System capability**: SystemCapability.Developtools.Bytrace
......@@ -25,16 +29,14 @@ Starts a trace task. **expectedTime** is an optional parameter, which specifies
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.|
| taskId | number | Yes| Task ID.|
| name | string | Yes| Name of a timeslice trace task.|
| taskId | number | Yes| ID of a timeslice trace task.|
| expectedTime | number | No| Expected duration of the trace, in ms.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example.
**Example**
```
```js
bytrace.startTrace("myTestFunc", 1);
bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms.
```
......@@ -44,7 +46,11 @@ bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is
finishTrace(name: string, taskId: number): void
Stops a trace task.
Marks the end of a timeslice trace task.
> **NOTE**
>
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**System capability**: SystemCapability.Developtools.Bytrace
......@@ -52,15 +58,13 @@ Stops a trace task.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the trace task to start.|
| taskId | number | Yes| Task ID.|
| name | string | Yes| Name of a timeslice trace task.|
| taskId | number | Yes| ID of a timeslice trace task.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**.
**Example**
```
```js
bytrace.finishTrace("myTestFunc", 1);
```
......@@ -91,9 +95,9 @@ bytrace.finishTrace("myTestFunc", 1);
traceByValue(name: string, count: number): void
Traces the value changes of a variable.
Defines the variable that indicates the number of timeslice trace tasks.
**System capability**: SystemCapability.Developtools.Bytrace
**System capability**: SystemCapability.HiviewDFX.HiTrace
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -103,7 +107,7 @@ Traces the value changes of a variable.
**Example**
```
```js
let traceCount = 3;
bytrace.traceByValue("myTestCount", traceCount);
traceCount = 4;
......
......@@ -2175,7 +2175,7 @@ Opens a file stream based on the file path. This API uses a promise to return th
| Type | Description |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise used to return the result.|
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example**
......@@ -2202,7 +2202,7 @@ Opens a file stream based on the file path. This API uses an asynchronous callba
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| path | string | Yes | Application sandbox path of the file. |
| mode | string | Yes | -&nbsp;**r**: Open a file for reading. The file must exist.<br>-&nbsp;**r+**: Open a file for both reading and writing. The file must exist.<br>-&nbsp;**w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>-&nbsp;**w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>-&nbsp;**a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>-&nbsp;**a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&lt;[Stream](#stream7)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
......@@ -2232,7 +2232,7 @@ Synchronously opens a stream based on the file path.
| Type | Description |
| ------------------ | --------- |
| [Stream](#stream7) | Stream opened.|
| [Stream](#stream) | Stream opened.|
**Example**
......@@ -2260,7 +2260,7 @@ Opens a file stream based on the file descriptor. This API uses a promise to ret
| Type | Description |
| --------------------------------- | --------- |
| Promise&lt;[Stream](#stream7)&gt; | Promise used to return the result.|
| Promise&lt;[Stream](#stream)&gt; | Promise used to return the result.|
**Example**
......@@ -2288,7 +2288,7 @@ Opens a file stream based on the file descriptor. This API uses an asynchronous
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| fd | number | Yes | File descriptor of the target file. |
| mode | string | Yes | -&nbsp;**r**: Open a file for reading. The file must exist.<br>-&nbsp;**r+**: Open a file for both reading and writing. The file must exist.<br>-&nbsp;**w**: Open a file for writing. If the file exists, clear its content. If the file does not exist, create a file.<br>-&nbsp;**w+**: Open a file for both reading and writing. If the file exists, clear its content. If the file does not exist, create a file.<br>-&nbsp;**a**: Open a file in append mode for writing at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).<br>-&nbsp;**a+**: Open a file in append mode for reading or updating at the end of the file. If the file does not exist, create a file. If the file exists, write data to the end of the file (the original content of the file is reserved).|
| callback | AsyncCallback&nbsp;&lt;[Stream](#stream7)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
| callback | AsyncCallback&nbsp;&lt;[Stream](#stream)&gt; | Yes | Callback invoked when the stream is open asynchronously. |
**Example**
......@@ -2319,7 +2319,7 @@ Synchronously opens a stream based on the file descriptor.
| Type | Description |
| ------------------ | --------- |
| [Stream](#stream7) | Stream opened.|
| [Stream](#stream) | Stream opened.|
**Example**
......
# User File Access and Management
The fileManager module provides APIs for accessing and managing user files. It interworks with the underlying file management services to implement media library and external card management, and provides capabilities for applications to query and create user files.
The **fileManager** module provides APIs for accessing and managing user files. It interworks with the underlying file management services to implement media library and external card management, and provides capabilities for applications to query and create user files.
>**NOTE**<br/>
>
......@@ -35,11 +35,9 @@ Obtains information about the root album or directory in asynchronous mode. This
**Example**
```js
filemanager.getRoot().then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
filemanager.getRoot().then((fileInfos) => {
for (var i = 0; i < fileInfos.length; i++) {
console.log("files:"+JSON.stringify(fileInfos));
}
}).catch((err) => {
console.log(err)
......@@ -69,14 +67,11 @@ Obtains information about the root album or directory in asynchronous mode. This
"name":"local"
}
};
filemanager.getRoot(options, (err, fileInfo)=>{
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
filemanager.getRoot(options, (err, fileInfos)=>{
for (var i = 0; i < fileInfos.length; i++) {
console.log("files:"+JSON.stringify(fileInfos));
}
});
```
## filemanager.listFile
......@@ -111,18 +106,17 @@ Obtains information about the second-level album or files in asynchronous mode.
**Example**
```js
// Obtain all files in the directory.
// Call listFile() and getRoot() to obtain the file URI.
let media_path = ""
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
// Obtain all files in the directory. You can use getRoot to obtain the directory URI.
filemanager.getRoot().then((fileInfos) => {
let file = fileInfos.find(item => item.name == "file_folder");
let path = file.path;
filemanager.listFile(path, "file").then((files) => {
console.log("files:" + JSON.stringify(files));
}).catch((err) => {
console.log("Failed to get file"+err);
console.log("failed to get files" + err);
});
}).catch((err) => {
console.log("failed to get root" + err);
});
```
......@@ -153,33 +147,18 @@ Obtains information about the second-level album or files in asynchronous mode.
**Example**
```js
// Call listFile() and getRoot() to obtain the file path.
let fileInfos = filemanager.getRoot();
let media_path = "";
for (let i = 0; i < fileInfos.length; i++) {
if (fileInfos[i].name == "image_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "audio_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "video_album") {
media_path = fileInfos[i].path;
} else if (fileInfos[i].name == "file_folder") {
media_path = fileInfos[i].path;
}
}
filemanager.listFile(media_path, "file")
.then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log("file:"+JSON.stringify(fileInfo));
}
}
}).catch((err) => {
console.log("Failed to get file"+err);
});
```
```js
// Obtain all files in the directory. You can use getRoot to obtain the directory URI.
filemanager.getRoot().then((fileInfos) => {
let file = fileInfos.find(item => item.name == "image_album");
let path = file.path;
filemanager.listFile(path, "image",function(err, files){
console.log("files:" + JSON.stringify(files));
})
}).catch((err) => {
console.log("failed to get root" + err);
});
```
## filemanager.createFile
......
# OS Account Management
The osAccount module provides basic capabilities for managing operating system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account, and storing OS account data to disks.
The **osAccount** module provides basic capabilities for managing operating system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling an OS account, and storing OS account data to disks.
> **NOTE**<br>
> 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.
......@@ -801,7 +801,7 @@ Obtains the OS account ID based on domain account information. This API uses an
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the ID of the OS account associated with the domain account.|
**Example**
......@@ -829,7 +829,7 @@ Obtains the OS account ID based on domain account information. This API uses a p
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ------------ |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.|
| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information.|
**Return value**
......@@ -1156,7 +1156,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
**Example**
......@@ -1187,7 +1187,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------------- | ---- | ---------------------- |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes | Domain account information. |
**Return value**
......@@ -1765,7 +1765,7 @@ Defines information about an OS account.
| isActived<sup>8+</sup> | boolean | Yes | Whether the OS account is activated. |
| isCreateCompleted<sup>8+</sup> | boolean | Yes | Whether the OS account information is complete. |
| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. |
| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. |
| domainInfo<sup>8+</sup> | [DomainAccountInfo](#domainaccountinfo8) | No | Domain account information. |
## DomainAccountInfo<sup>8+</sup>
......
......@@ -263,12 +263,6 @@ Enables the display of a confirm dialog box before returning to the previous pag
enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({
message: 'Message Info',
success: function() {
console.log('success');
},
fail: function() {
console.log('fail');
},
});
}
}
......@@ -434,4 +428,5 @@ Describes the page routing options.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> The page routing stack supports a maximum of 32 pages.
......@@ -66,6 +66,7 @@ export default {
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> The page routing stack supports a maximum of 32 pages.
......@@ -182,6 +183,7 @@ export default {
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> In the example, the **uri** field indicates the page route, which is specified by the **pages** list in the **config.json** file.
## router.getParams
......@@ -375,8 +377,8 @@ Defines the **EnableAlertBeforeBackPage** parameters.
| Name | Type | Mandatory | Description |
| -------- | ------------------------ | ---- | ------------------------- |
| message | string | Yes | Content displayed in the confirm dialog box. |
| success | (errMsg: string) => void | No | Called when a dialog box is displayed. **errMsg** indicates the returned information. |
| fail | (errMsg: string) => void | No | Called when the API fails to be called. **errMsg** indicates the returned information.|
| success | (errMsg: string) => void | No | Called when the **OK** button in the confirm dialog box is clicked. **errMsg** indicates the returned information. |
| cancel | (errMsg: string) => void | No | Called when the **Cancel** button in the confirm dialog box is clicked. **errMsg** indicates the returned information. |
| complete | () => void | No | Called when the API call is complete. |
## DisableAlertBeforeBackPageOptions<sup>6+</sup>
......@@ -387,8 +389,8 @@ Define the **DisableAlertBeforeBackPage** parameters.
| Name | Type | Mandatory | Description |
| -------- | ------------------------ | ---- | ------------------------- |
| success | (errMsg: string) => void | No | Called when a dialog box is displayed. **errMsg** indicates the returned information. |
| fail | (errMsg: string) => void | No | Called when the API fails to be called. **errMsg** indicates the returned information.|
| success | (errMsg: string) => void | No | Called when the dialog box is closed. **errMsg** indicates the returned information. |
| cancel | (errMsg: string) => void | No | Called when the dialog box fails to be closed. **errMsg** indicates the returned information. |
| complete | () => void | No | Called when the API call is complete. |
## ParamsInterface
......
......@@ -12,9 +12,9 @@ App permissions are used to protect the following objects:
Without the required permissions, an app cannot access or perform operations on the target object. Permissions must be clearly defined for apps. With well-defined app permissions, the system can standardize the behavior of apps and protect user privacy. Before an app accesses the target object, the target object verifies the app's permissions and denies the access if the app does not have required permissions.
Currently, ATM performs app permission verification based on the token identity (Token ID). A token ID identifies an app. The ATM manages app permissions based on the app's token ID.
Currently, ATM verifies app permissions based on the token identity (Token ID). A token ID identifies an app. The ATM manages app permissions based on the app's token ID.
## How to Develop
## Permission Workflow
Determine the permissions required for an app to access data or perform an operation. Declare the required permissions in the app installation package.
......@@ -22,13 +22,13 @@ Determine whether the required permissions need to be authorized by users. If ye
After the user grants permissions to the app, the app can access the data or perform the operation.
The figure below shows the process.
The figure below shows the permission workflow.
![](figures/figure1.png)
## When to Use
### Scenarios
### Example Scenarios
The following describes two common scenarios.
......@@ -62,7 +62,7 @@ Observe the following principles for permission management:
To protect user privacy, ATM defines different permission levels based on the sensitivity of the data involved or the security threat of the ability.
### App APL
### App APLs
The ability privilege level (APL) defines the priority of the app permission requested. Apps of different APLs can apply for permissions of different levels.
......@@ -76,9 +76,9 @@ The table below describes the APLs.
By default, apps are of the normal APL.
For the app of the system_basic or system_core APL, declare the app APL level in the **apl** field in the app's profile, and use the profile signing tool to generate a certificate when developing the app installation package. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
For the app of the system_basic or system_core APL, declare the app APL in the **apl** field in the app's profile, and use the profile signing tool to generate a certificate when developing the app installation package. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
### Permission Levels
### Levels of Permissions
The permissions open to apps vary with the permission level. The permission levels include the following in ascending order of seniority.
......@@ -121,11 +121,11 @@ If the permission required by an app has higher level than the app's APL, you ca
In addition to the preceding [authorization processes](#authorization-processes), you must declare the ACL.
In other words, in addition to declaring the required permissions in the **config.json** file, you must declare the high-level permissions in the app's [profile](accesstoken-guidelines.md#declaring-the-acl). The subsequent steps of authorization are the same.
In other words, in addition to declaring the required permissions in the **config.json** file, you must [declare the ACL](accesstoken-guidelines.md#declaring-the-acl) in the app's profile. The subsequent steps of authorization are the same.
**NOTE**
**NOTICE**
Declare the target ACL in the **acl** field of the app's profile in the app installation package, and generate a certificate using the profile signing tool. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
Declare the target ACL in the **acls** field of the app's profile in the app installation package, and generate a certificate using the profile signing tool. For details about the signing process, see [Hapsigner Guide](hapsigntool-guidelines.md).
## Permission Authorization Modes
......@@ -149,9 +149,7 @@ Permissions can be classified into the following types based on the authorizatio
### Authorization Processes
The process for an app obtaining the required permissions varies
depending on the permission authorization mode.
The process for an app obtaining the required permissions varies depending on the permission authorization mode.
- For a system_grant permission, you need to [declare the permission](accesstoken-guidelines.md) in the **config.json** file. The permission will be pre-granted when the app is installed.
......@@ -165,7 +163,7 @@ The procedure is as follows:
2. Associate the object that requires the permissions in the app with the target permissions. In this way, the user knows the operations to be granted with the specified permissions.
3. Check whether the user has granted the required permissions to the app when the app is running. If yes, the app can access the data or perform the operation. If the user has not granted the permissions to the app, display a dialog box requesting the user authorization when the app attempts to access the data or perform the operation.
3. Check whether the user has granted the required permissions to the app when the app is running. If yes, the app can access the data or perform the operation. If the user has not granted the permissions to the app, display a dialog box requesting the user authorization when the app attempts to access the data.
4. Check the user authorization result. Allow the next step only after the user has granted the permissions to the app.
......
......@@ -52,7 +52,7 @@ The camera module encapsulates camera operations in camera preview, photographin
| API | Description |
| ------------------------------------------------------------ | ---------------------------- |
| CamRetCode GetStreamOperator(<br> const OHOS::sptr<IStreamOperatorCallback> &callback,<br> OHOS::sptr<IStreamOperator> &streamOperator) | Obtains the stream controller. |
| CamRetCode UpdateSettings(const std::shared_ptr<CameraSetting> &settingss) | Updates device control parameters. |
| CamRetCode UpdateSettings(const std::shared_ptr<CameraSetting> &settings) | Updates device control parameters. |
| CamRetCode SetResultMode(const ResultCallbackMode &mode) | Sets the result callback mode and function.|
| CamRetCode GetEnabledResults(std::vector<MetaType> &results) | Obtains the enabled ResultMeta. |
| CamRetCode EnableResult(const std::vector<MetaType> &results) | Enables specific ResultMeta. |
......@@ -730,7 +730,7 @@ There is a camera demo in the **/drivers/peripheral/camera/hal/init** directory.
"-o | --offline stream offline test\n"
"-c | --capture capture one picture\n"
"-w | --set WB Set white balance Cloudy\n"
"-v | --video capture Viedeo of 10s\n"
"-v | --video capture Video of 10s\n"
"-a | --Set AE Set Auto exposure\n"
"-f | --Set Flashlight Set flashlight ON 5s OFF\n"
"-q | --quit stop preview and quit this app\n");
......
......@@ -115,7 +115,7 @@ Data提供方可以自定义数据的增、删、改、查,以及文件打开
其中,基础依赖包包括:
- @ohos.ability.featureAbility
- @ohos.data.dataability
- @ohos.data.dataAbility
- @ohos.data.rdb
#### DataAbility接口开发指导
......
......@@ -58,7 +58,7 @@ Ability功能如下(Ability类,具体的API详见[接口文档](../reference
```
import AbilityStage from "@ohos.application.AbilityStage"
```
2. 实现AbilityStage接口。
2. 实现AbilityStage接口,接口生成的默认相对路径:entry\src\main\ets\Application\AbilityStage.ts
```ts
export default class MyAbilityStage extends AbilityStage {
onCreate() {
......@@ -70,7 +70,7 @@ Ability功能如下(Ability类,具体的API详见[接口文档](../reference
```js
import Ability from '@ohos.application.Ability'
```
4. 实现Ability生命周期接口。
4. 实现Ability生命周期接口,接口默认生成的相对路径:entry\src\main\ets\MainAbility\MainAbility.ts
`onWindowStageCreate(windowStage)`中通过loadContent接口设置应用要加载的页面,window接口的使用详见[窗口开发指导](../windowmanager/window-guidelines.md)
```ts
......@@ -87,7 +87,7 @@ Ability功能如下(Ability类,具体的API详见[接口文档](../reference
console.log("MainAbility onWindowStageCreate")
windowStage.loadContent("pages/index").then((data) => {
console.log("MainAbility load content succeed with data: " + JSON.stringify(data))
console.log("MainAbility load content succeed")
}).catch((error) => {
console.error("MainAbility load content failed with error: "+ JSON.stringify(error))
})
......@@ -107,7 +107,8 @@ Ability功能如下(Ability类,具体的API详见[接口文档](../reference
}
```
### 获取AbilityStage及Ability的配置信息
AbilityStage类及Ability类均拥有context属性,应用可以通过`this.context`获取Ability实例的上下文,进而获取详细的配置信息。如下示例展示了AbilityStage通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下:
AbilityStage类及Ability类均拥有context属性,应用可以通过`this.context`获取Ability实例的上下文,进而获取详细的配置信息。
如下示例展示了AbilityStage通过context属性获取包代码路径、hap包名、ability名以及系统语言的方法。具体示例代码如下:
```ts
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
......@@ -140,7 +141,7 @@ export default class MainAbility extends Ability {
console.log("MainAbility ability name" + abilityInfo.name)
let config = this.context.config
console.log("MyAbilityStage config language" + config.language)
console.log("MainAbility config language" + config.language)
}
}
```
......@@ -269,7 +270,7 @@ function getRemoteDeviceId() {
```
向用户申请数据同步'ohos.permission.DISTRIBUTED_DATASYNC'的权限。申请授权示例代码见[应用向用户申请授权](###应用向用户申请授权)
### 指定页面启动Ability
当Ability的启动模式设置为单例时,若Ability已被拉起,再次启动Ability会触发onNewWant回调。应用开发者可以通过want传递启动参数,比如希望指定页面启动Ability,可以通过want中的uri参数或parameters参数传递pages信息。目前,Stage模型中Ability暂时无法直接使用router的能力,可以将启动参数传递给自定义组件,在自定义组件的生命周期中调用router接口显示指定页面。具体示例代码如下:
当Ability的启动模式设置为单例时,若Ability已被拉起,再次启动Ability,不会触发onCreate,只会触发onNewWant回调。应用开发者可以通过want传递启动参数,比如希望指定页面启动Ability,可以通过want中的uri参数或parameters参数传递pages信息。目前,Stage模型中Ability暂时无法直接使用router的能力,可以将启动参数传递给自定义组件,在自定义组件的生命周期中调用router接口显示指定页面。具体示例代码如下:
使用startAbility再次拉起Ability,通过want中的uri参数传递页面信息:
```ts
......@@ -311,7 +312,7 @@ struct Index {
console.info('Index onPageShow')
let newWant = globalThis.newWant
if (newWant.hasOwnProperty("uri")) {
router.push({ uri: newWant.uri });
router.push({ url: newWant.uri });
globalThis.newWant = undefined
}
}
......
......@@ -26,7 +26,7 @@ ExtensionAbility,是Stage模型中新增的扩展组件的基类,一般用
1.创建ServiceExtensionAbility
开发者在创建TS文件中自定义类继承ServiceExtensionAbility,重写基类回调函数,示例如下:
开发者在创建TS文件中自定义类继承ServiceExtensionAbility,重写基类回调函数,接口生成的默认相对路径:entry\src\main\ets\ServiceExtAbility\ServiceExtAbility.ts,示例如下:
```js
import rpc from '@ohos.rpc'
......
......@@ -164,7 +164,7 @@
import data_rdb from '@ohos.data.rdb'
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",}
const STORE_CONFIG = {name: "rdbstore.db"}
data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
rdbStore.executeSql(CREATE_TABLE_TEST )
console.info('create table done.')
......@@ -179,7 +179,7 @@
```js
var u8 = new Uint8Array([1, 2, 3])
const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,}
const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8}
let insertPromise = rdbStore.insert("test", valueBucket)
```
......
......@@ -75,20 +75,22 @@
1. 准备工作,导入@ohos.data.storage以及相关的模块到开发环境。
```js
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility' // 用于获取文件存储路径
import dataStorage from '@ohos.data.storage';
import featureAbility from '@ohos.ability.featureAbility'; // 用于获取文件存储路径
```
2. 获取Storage实例。
读取指定文件,将数据加载到Storage实例,用于数据操作。
```js
var context = featureAbility.getContext()
context.getFilesDir().then(() => {
var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
});
let promise = dataStorage.getStorage(path + '/mystore')
let promise = dataStorage.getStorage(path + '/mystore');
```
3. 存入数据。
......@@ -97,14 +99,14 @@
```js
promise.then((storage) => {
let getPromise = storage.put('startup', 'auto') // 保存数据到缓存的storage示例中。
let getPromise = storage.put('startup', 'auto'); // 保存数据到缓存的storage示例中。
getPromise.then(() => {
console.info("Put the value of startup successfully.")
console.info("Succeeded in putting the value of startup.");
}).catch((err) => {
console.info("Put the value of startup failed with err: " + err)
console.info("Failed to put the value of startup failed with err: " + err);
})
}).catch((err) => {
console.info("Get the storage failed")
console.info("Failed to get the storage.");
})
```
......@@ -116,12 +118,14 @@
promise.then((storage) => {
let getPromise = storage.get('startup', 'default')
getPromise.then((value) => {
console.info("The value of startup is " + value)
console.info("The value of startup is " + value);
}).catch((err) => {
console.info("Get the value of startup failed with err: " + err)
console.info("Failed to get the value of startup with err: " + err);
})
}).catch((err) => {
console.info("Get the storage failed")})
console.info("Failed to get the storage.")
})
```
5. 数据持久化。
......@@ -139,15 +143,15 @@
```js
promise.then((storage) => {
var observer = function (key) {
console.info("The key of " + key + " changed.")
console.info("The key of " + key + " changed.");
}
storage.on('change', observer)
storage.putSync('startup', 'auto') // 修改storage存储数据
storage.flushSync() // 触发订阅者回调方法
storage.putSync('startup', 'auto'); // 修改storage存储数据
storage.flushSync(); // 触发订阅者回调方法
storage.off('change', observer) // 注销数据变化订阅
storage.off('change', observer); // 注销数据变化订阅
}).catch((err) => {
console.info("Get the storage failed")
console.info("Failed to get the storage.");
})
```
......@@ -156,11 +160,13 @@
使用deleteStorage方法从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。删除后,数据及文件将不可恢复。
```js
let promise = dataStorage.deleteStorage(path + '/mystore')
let promise = dataStorage.deleteStorage(path + '/mystore');
promise.then(() => {
console.info("Deleted successfully.")
console.info("Succeeded in deleting the storage.");
}).catch((err) => {
console.info("Deleted failed with err: " + err)})
console.info("Failed to delete the storage with err: " + err);
})
```
## 相关实例
针对轻量级数据存储开发,有以下相关实例可供参考:
......
......@@ -34,10 +34,10 @@
1. 获取设备上传感器的数据,需要在“config.json”里面进行配置请求权限。具体如下:
```
”reqPermissions“:[
"reqPermissions":[
{
"name":"ohos.permission.ACCELEROMETER",
"reason"":"",
"reason":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
......@@ -45,7 +45,7 @@
},
{
"name":"ohos.permission.GYROSCOPE",
"reason"":"",
"reason":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
......@@ -53,7 +53,7 @@
},
{
"name":"ohos.permission.ACTIVITY_MOTION",
"reason"":"ACTIVITY_MOTION_TEST",
"reason":"ACTIVITY_MOTION_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
......@@ -61,7 +61,7 @@
},
{
"name":"ohos.permission.READ_HEALTH_DATA",
"reason"":"HEALTH_DATA_TEST",
"reason":"HEALTH_DATA_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
......
......@@ -595,7 +595,7 @@ connectAbility(want: Want, options: ConnectOptions): number
| 类型 | 说明 |
| -------- | -------- |
| number | 连接Ability的代码 |
| number | 返回Ability连接的结果code。 |
**示例**
```js
......@@ -606,7 +606,7 @@ var want = {
}
var options = {
onConnect: (elementName, remote) => {
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' remote)
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' + remote)
},
onDisconnect: (elementName) => {
console.log('connectAbility onDisconnect, elementName: ' + elementName)
......@@ -615,8 +615,8 @@ var options = {
console.log('connectAbility onFailed, code: ' + code)
}
}
this.context.connectAbility(want, options) {
console.log('code: ' + code)
let result = this.context.connectAbility(want, options) {
console.log('code: ' + result)
}
```
......@@ -652,7 +652,7 @@ var want = {
var accountId = 111;
var options = {
onConnect: (elementName, remote) => {
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' remote)
console.log('connectAbility onConnect, elementName: ' + elementName + ', remote: ' + remote)
},
onDisconnect: (elementName) => {
console.log('connectAbility onDisconnect, elementName: ' + elementName)
......
# 性能打点
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
本模块提供了追踪进程轨迹。
> **说明:**
> - 从API Version 8开始,该接口不再维护,推荐使用新接口[`@ohos.hiTraceMeter`](js-apis-hitracemeter.md)。
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```js
import bytrace from '@ohos.bytrace';
```
## bytrace.startTrace
startTrace(name: string, taskId: number, expectedTime?: number): void
标记一个预追踪耗时任务的开始,expectedTime是可选参数,标识该任务的期望耗时。
标记一个时间片跟踪任务的开始。
> **说明:**
> 如果有多个相同name的任务需要追踪或者对同一个任务要追踪多次,并且这些跟踪任务会同时被执行,则每次调用startTrace的taskId必须不一致。如果具有相同name的跟踪任务是串行执行的,则taskId可以相同。在下面bytrace.finishTrace的示例中会举例说明。
**系统能力:** SystemCapability.Developtools.Bytrace
**系统能力:** SystemCapability.HiviewDFX.HiTrace
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| name | string | 是 | 要追踪的任务名称 |
| taskId | number | 是 | 任务id |
| expectedTime | number | 否 | 期望的耗时时间,单位:ms |
| name | string | 是 | 时间片跟踪任务名称 |
| taskId | number | 是 | 时间片跟踪任务id |
| expectedTime | number | 否 | 期望的耗时时间(单位:ms) |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果有多个相同name的任务需要追踪或者对同一个任务要追踪多次,并且这些会同时被执行,则每次调用startTrace的taskId必须不一致。如果具有相同name的任务是串行执行的,则taskId可以相同。在下面bytrace.finishTrace的示例中会举例说明。
**示例:**
```
```js
bytrace.startTrace("myTestFunc", 1);
bytrace.startTrace("myTestFunc", 1, 5); //从startTrace到finishTrace流程的耗时期望为5ms
bytrace.startTrace("myTestFunc", 1, 5); // 从startTrace到finishTrace流程的期望耗时为5ms
```
## bytrace.finishTrace
finishTrace(name: string, taskId: number): void
标记一个预追踪耗时任务的结束。
标记一个时间片跟踪事件的结束。
> **说明:**<br>
> finishTrace的name和taskId必须与流程开始的startTrace对应参数值一致。
**系统能力:** SystemCapability.Developtools.Bytrace
**系统能力:** SystemCapability.HiviewDFX.HiTrace
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| name | string | 是 | 要追踪的任务名称 |
| taskId | number | 是 | 任务id |
| name | string | 是 | 时间片跟踪任务名称 |
| taskId | number | 是 | 时间片跟踪任务id |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> finishTrace的name和taskId必须与流程开始的startTrace对应参数值一致。
**示例:**
```
```js
bytrace.finishTrace("myTestFunc", 1);
```
```
//踪并行执行的同名任务
//踪并行执行的同名任务
bytrace.startTrace("myTestFunc", 1);
//业务流程......
bytrace.startTrace("myTestFunc", 2); //第二个追踪的任务开始,同时第一个追踪的同名任务还没结束,出现了并行执行,对应接口的taskId需要不同。
//业务流程......
// 业务流程......
bytrace.startTrace("myTestFunc", 2); // 第二个跟踪任务开始,同时第一个同名跟踪任务还没结束,出现了并行执行,对应接口的taskId需要不同
// 业务流程......
bytrace.finishTrace("myTestFunc", 1);
//业务流程......
// 业务流程......
bytrace.finishTrace("myTestFunc", 2);
```
```
//踪串行执行的同名任务
//踪串行执行的同名任务
bytrace.startTrace("myTestFunc", 1);
//业务流程......
bytrace.finishTrace("myTestFunc", 1); //第一个追踪的任务结束
//业务流程......
bytrace.startTrace("myTestFunc", 1); //第二个追踪的同名任务开始,同名的待追踪任务串行执行。
//业务流程......
// 业务流程......
bytrace.finishTrace("myTestFunc", 1); // 第一个跟踪任务结束
// 业务流程......
bytrace.startTrace("myTestFunc", 1); // 第二个跟踪任务开始,同名跟踪任务串行执行
// 业务流程......
bytrace.finishTrace("myTestFunc", 1);
```
## bytrace.traceByValue
traceByValue(name: string, count: number): void
用来标记一个预追踪的数值变量,该变量的数值会不断变化。
标记预追踪耗时任务的数值变量,该变量的数值会不断变化。
**系统能力:** SystemCapability.Developtools.Bytrace
**系统能力:** SystemCapability.HiviewDFX.HiTrace
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| name | string | 是 | 要追踪的数值变量名称 |
| count | number | 是 | 变量的值 |
| name | string | 是 | 数值变量的名称 |
| count | number | 是 | 数值变量的值 |
**示例:**
```
```js
let traceCount = 3;
bytrace.traceByValue("myTestCount", traceCount);
traceCount = 4;
bytrace.traceByValue("myTestCount", traceCount);
//业务流程......
// 业务流程......
```
......@@ -23,7 +23,7 @@ isLoggable(domain: number, tag: string, level: LogLevel) : boolean
| 参数名 | 类型 | 必填 | 说明 |
| ------ | --------------------- | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| level | [LogLevel](#loglevel) | 是 | 日志级别。 |
......@@ -67,7 +67,7 @@ DEBUG级别的日志在正式发布版本中默认不被打印,只有在调试
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。<br>隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\<private>过滤回显。 |
| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
......@@ -82,7 +82,7 @@ hilog.debug(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志:
```
```txt
08-05 12:21:47.579 2695-2703/com.example.myapplication D 00001/testTag: hello World <private>
```
......@@ -98,7 +98,7 @@ info(domain: number, tag: string, format: string, ...args: any[]) : void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。<br/>隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\<private>过滤回显。 |
| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
......@@ -113,7 +113,7 @@ hilog.info(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志:
```
```txt
08-05 12:21:47.579 2695-2703/com.example.myapplication I 00001/testTag: hello World <private>
```
......@@ -129,7 +129,7 @@ warn(domain: number, tag: string, format: string, ...args: any[]) : void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。<br/>隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\<private>过滤回显。 |
| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
......@@ -144,7 +144,7 @@ hilog.warn(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志:
```
```txt
08-05 12:21:47.579 2695-2703/com.example.myapplication W 00001/testTag: hello World <private>
```
......@@ -160,7 +160,7 @@ error(domain: number, tag: string, format: string, ...args: any[]) : void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。<br/>隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\<private>过滤回显。 |
| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
......@@ -175,7 +175,7 @@ hilog.error(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志:
```
```txt
08-05 12:21:47.579 2695-2703/com.example.myapplication E 00001/testTag: hello World <private>
```
......@@ -191,7 +191,7 @@ fatal(domain: number, tag: string, format: string, ...args: any[]) : void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF,开发者可根据需要自定义。 |
| domain | number | 是 | 日志对应的领域标识,范围是0x0~0xFFFF<br/>建议开发者在应用内根据需要自定义划分。 |
| tag | string | 是 | 指定日志标识,可以为任意字符串,建议用于标识调用所在的类或者业务行为。 |
| format | string | 是 | 格式字符串,用于日志的格式化输出。格式字符串中可以设置多个参数,参数需要包含参数类型、隐私标识。<br/>隐私标识分为{public}和{private},缺省为{private}。标识{public}的内容明文输出,标识{private}的内容以\<private>过滤回显。 |
| args | any[] | 是 | 与格式字符串format对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
......@@ -206,6 +206,6 @@ hilog.fatal(0x0001, "testTag", "%{public}s World %{private}d", "hello", 3);
字符串`"hello"`填入`%{public}s`,整型数`3`填入`%{private}d`,输出日志:
```
```txt
08-05 12:21:47.579 2695-2703/com.example.myapplication F 00001/testTag: hello World <private>
```
\ No newline at end of file
......@@ -115,7 +115,7 @@ back(options?: RouterOptions ): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | 是 | 返回页面描述信息,其中参数url指路由跳转时会返回到指定url的界面,如果页面栈上没有url页面,则不响应该情况。如果url未设置,则返回上一页。 |
| options | [RouterOptions](#routeroptions) | 是 | 返回页面描述信息,其中参数url指路由跳转时会返回到指定url的界面,如果页面栈上没有url页面,则不响应该情况。如果url未设置,则返回上一页,页面栈里面的page不会回收,出栈后会回收。 |
**示例:**
```js
......
......@@ -1124,13 +1124,14 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac
**示例:**
```js
var names = ["status", "navigation"];
// 此处以不显示导航栏、状态栏为例
var names = [];
windowClass.setSystemBarEnable(names, (err, data) => {
if (err.code) {
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
});
```
......@@ -1157,12 +1158,13 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise&lt;void&gt;
**示例:**
```js
var names = ["status", "navigation"];
// 此处以不显示导航栏、状态栏为例
var names = [];
let promise = windowClass.setSystemBarEnable(names);
promise.then((data)=> {
console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data));
console.info('Succeeded in setting the system bar to be invisible. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err));
console.error('Failed to set the system bar to be invisible. Cause:' + JSON.stringify(err));
});
```
......
......@@ -14,8 +14,8 @@
| onLayoutReady | Function | 自定义组件布局完成 | 自定义组件插入Page组件树后,将会对自定义组件进行布局计算,调整其内容元素尺寸与位置,当布局计算结束后触发该回调。 |
| onDetached | Function | 自定义组件摘除 | 自定义组件摘除时,触发该回调,常用于停止动画或异步逻辑停止执行的场景。 |
| onDestroy | Function | 自定义组件销毁 | 自定义组件销毁时,触发该回调,常用于资源释放。 |
| onPageShow | Function | 自定义组件Page显示 | 自定义组件所在Page显示后,触发该回调。 |
| onPageHide | Function | 自定义组件Page隐藏 | 自定义组件所在Page隐藏后,触发该回调。 |
| onShow | Function | 自定义组件Page显示 | 自定义组件所在Page显示后,触发该回调。 |
| onHide | Function | 自定义组件Page隐藏 | 自定义组件所在Page隐藏后,触发该回调。 |
## 示例
......@@ -42,10 +42,10 @@ export default {
onDetached() {
this.value = ""
},
onPageShow() {
onShow() {
console.log("Page显示")
},
onPageHide() {
onHide() {
console.log("Page隐藏")
}
}
......
......@@ -10,28 +10,10 @@
| 名称 | 参数类型 | 默认值 | 描述 |
| ---------- | ---------------------------------------- | --------------- | ----------------------- |
| duration | number | 1000 | 单位为毫秒,默认动画时长为1000毫秒。 |
| curve | Curve | Curve.Linear | 默认曲线为线性。 |
| curve | [Curve](ts-appendix-enums.md#curve) | Curve.Linear | 默认曲线为线性。 |
| delay | number | 0 | 单位为毫秒,默认不延时播放。 |
| iterations | number | 1 | 默认播放一次,设置为-1时表示无限次播放。 |
| playMode | [PlayMode](ts-appendix-enums.md#playmode枚举值说明) | PlayMode.Normal | 设置动画播放模式,默认播放完成后重头开始播放。 |
## 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)。 |
| playMode | [PlayMode](ts-appendix-enums.md#playmode) | PlayMode.Normal | 设置动画播放模式,默认播放完成后重头开始播放。 |
## 示例
......
......@@ -42,7 +42,7 @@ Image(src: string | PixelMap | Resource)
| 名称 | 参数类型 | 默认值 | 描述 |
| --------------------- | ------------------------------------------------------- | -------- | ------------------------------------------------------------ |
| alt | string \| [Resource](../../ui/ts-types.md#resource类型) | - | 加载时显示的占位图。支持本地图片和网络路径。 |
| objectFit | ImageFit | Cover | 设置图片的缩放类型。 |
| objectFit | [ImageFit](ts-appendix-enums.md#imagefit) | Cover | 设置图片的缩放类型。 |
| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat枚举说明) | NoRepeat | 设置图片的重复样式。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。 |
| interpolation | ImageInterpolation | None | 设置图片的插值效果,即减轻低清晰度图片在放大显示的时候出现的锯齿问题,仅针对图片放大插值。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。<br/>>&nbsp;-&nbsp;PixelMap资源不支持该属性。 |
| renderMode | ImageRenderMode | Original | 设置图片渲染的模式。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;-&nbsp;svg类型图源不支持该属性。 |
......@@ -53,16 +53,6 @@ Image(src: string | PixelMap | Resource)
| autoResize | boolean | true | 是否需要在图片解码过程中对图源做resize操作,该操作会根据显示区域的尺寸决定用于绘制的图源尺寸,有利于减少内存占用。 |
| syncLoad<sup>8+</sup> | boolean | false | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。 |
## ImageFit枚举说明
| 名称 | 描述 |
| --------- | -------------------------------- |
| Cover | 保持宽高比进行缩小或者放大,使得图片两边都大于或等于显示边界。 |
| Contain | 保持宽高比进行缩小或者放大,使得图片完全显示在显示边界内。 |
| Fill | 不保持宽高比进行放大缩小,使得图片填充满显示边界。 |
| None | 保持原有尺寸显示。通常配合objectRepeat属性一起使用。 |
| ScaleDown | 保持宽高比显示,图片缩小或者保持不变。 |
## ImageInterpolation枚举说明
| 名称 | 描述 |
......
......@@ -27,30 +27,14 @@ ImageAnimator()
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| ---------- | ---------------------------------------- | -------- | ---- | ---------------------------------------- |
| images | Array&lt;{<br/>src:string,<br/>width?:Length,<br/>height?:Length,<br/>top?:Length,<br/>left?:Length,<br/>duration?:number<br/>}&gt; | [] | 是 | 设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小、图片位置和图片播放时长信息。详细说明如下:<br/>src:图片路径,图片格式为svg,png和jpg。<br/>width:图片宽度。<br/>height:图片高度。<br/>top:图片相对于组件左上角的纵向坐标。<br/>left:图片相对于组件左上角的横向坐标。<br/>duration:每一帧图片的播放时长,单位毫秒。 |
| state | AnimationStatus | Initial | 否 | 默认为初始状态,用于控制播放状态。 |
| state | [AnimationStatus](ts-appendix-enums.md#animationstatus) | Initial | 否 | 默认为初始状态,用于控制播放状态。 |
| duration | number | 1000 | 否 | 单位为毫秒,默认时长为1000ms;duration为0时,不播放图片;值的改变只会在下一次循环开始时生效;当images中设置了单独的duration后,该属性设置无效。 |
| reverse | boolean | false | 否 | 设置播放顺序。false表示从第1张图片播放到最后1张图片;&nbsp;true表示从最后1张图片播放到第1张图片。 |
| fixedSize | boolean | true | 否 | 设置图片大小是否固定为组件大小。&nbsp;true表示图片大小与组件大小一致,此时设置图片的width&nbsp;、height&nbsp;、top&nbsp;和left属性是无效的。false表示每一张图片的&nbsp;width&nbsp;、height&nbsp;、top和left属性都要单独设置。 |
| preDecode | number | 0 | 否 | 是否启用预解码,默认值为0,即不启用预解码,如该值设为2,则播放当前页时会提前加载后面两张图片至缓存以提升性能。 |
| fillMode | FillMode | Forwards | 否 | 设置动画开始前和结束后的状态,可选值参见FillMode说明。 |
| fillMode | [FillMode](ts-appendix-enums.md#fillmode) | Forwards | 否 | 设置动画开始前和结束后的状态,可选值参见FillMode说明。 |
| iterations | number | 1 | 否 | 默认播放一次,设置为-1时表示无限次播放。 |
## AnimationStatus枚举说明
| 名称 | 描述 |
| ------- | --------- |
| Initial | 动画初始状态。 |
| Running | 动画处于播放状态。 |
| Paused | 动画处于暂停状态。 |
| Stopped | 动画处于停止状态。 |
## FillMode枚举值说明
| 名称 | 描述 |
| -------- | ---------------- |
| None | 播放完成后恢复初始状态。 |
| Forwards | 播放完成后保持动画结束时的状态。 |
## 事件
| 名称 | 功能描述 |
......
......@@ -27,7 +27,7 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
| --------- | ---------------------------------------- | ---- | --------------------------- | ----------------------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | - | 可滚动组件的控制器。用于与可滚动组件进行绑定。 |
| direction | ScrollBarDirection | 否 | ScrollBarDirection.Vertical | 滚动条的方向,控制可滚动组件对应方向的滚动。 |
| state | BarState | 否 | BarState.Auto | 滚动条状态。 |
| state | [BarState](ts-appendix-enums.md#barstate) | 否 | BarState.Auto | 滚动条状态。 |
> **说明:**
> ScrollBar组件负责定义可滚动区域的行为样式,ScrollBar的子节点负责定义滚动条的行为样式。
......@@ -41,13 +41,6 @@ ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: B
| Vertical | 纵向滚动条。 |
| Horizontal | 横向滚动条。 |
## BarState枚举说明
| 名称 | 描述 |
| ---- | --------------------- |
| On | 常驻显示。 |
| Off | 不显示。 |
| Auto | 按需显示(触摸时显示,无操作2s后消失)。 |
## 示例
......
......@@ -17,10 +17,10 @@ PanGesture(options?: { fingers?: number, direction?: PanDirection, distance?: nu
**参数:**
| 参数名称 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | ------------ | ---- | ---- | ---------------------------------- |
| --------- | ------------ | ---- | ------ | ------------------------------------------------------------ |
| fingers | number | 否 | 1 | 触发滑动的最少手指数,最小为1指,&nbsp;最大取值为10指。 |
| direction | PanDirection | 否 | All | 设置滑动方向,此枚举值支持逻辑与(&amp;)和逻辑或(\|)运算。 |
| distance | number | 否 | 5.0 | 最小滑动识别距离,单位为vp。 |
| distance | number | 否 | 5.0 | 最小滑动识别距离,单位为vp。<br/>**说明:**<br/>> tab滑动与该拖动手势事件同时存在时,可将distance值设为1,使拖动更灵敏,避免造成事件错乱。 |
## PanDirection枚举说明
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册