提交 51313874 编写于 作者: 关明月 提交者: Gitee

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

Signed-off-by: N关明月 <guanmingyue@huawei.com>
......@@ -7,9 +7,11 @@
The OpenHarmony application framework has two models: Feature Ability (FA) model and stage model. Correspondingly, there are two sets of context mechanisms. **application/BaseContext** is a common context base class. It uses the **stageMode** attribute to specify whether the context is used for the stage model.
- FA model
Only the methods in **app/Context** can be used for the context in the FA model. Both the application-level context and ability-level context are instances of this type. If an ability-level method is invoked in the application-level context, an error occurs. Therefore, you must pay attention to the actual meaning of the **Context** instance.
- Stage model
The stage model has the following types of contexts: **application/Context**, **application/ApplicationContext**, **application/AbilityStageContext**, **application/ExtensionContext**, **application/AbilityContext**, and **application/FormExtensionContext**. For details about these contexts and how to use them, see [Context in the Stage Model](#context-in-the-stage-model).
![contextIntroduction](figures/contextIntroduction.png)
......
......@@ -13,7 +13,7 @@ The **DataShare** module allows an application to manage its own data and share
|query?(uri: string, predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;Object&gt;): void|Queries data from the database.|
|delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void|Deletes data from the database.|
For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md).
For more information, see [DataShareExtensionAbility](../reference/apis/js-apis-application-DataShareExtensionAbility.md).
**Table 2** APIs of the data consumer
......@@ -25,11 +25,11 @@ For more details, see [DataShareExtensionAbility](../reference/apis/js-apis-appl
| query(uri: string, predicates: DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;DataShareResultSet&gt;): void | Queries data from the database. |
| delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback&lt;number&gt;): void | Deletes one or more data records from the database.|
For more details, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md).
For more information, see [DataShareHelper](../reference/apis/js-apis-data-dataShare.md).
## When to Use
There are two roles in **DataShare**.
There are two roles in **DataShare**:
- Data provider: adds, deletes, modifies, and queries data, opens files, and shares data.
- Data consumer: accesses the data provided by the provider using **DataShareHelper**.
......@@ -41,10 +41,10 @@ Examples are given below.
1. Import the dependencies.
```ts
import Extension from '@ohos.application.DataShareExtensionAbility'
import Extension from '@ohos.application.DataShareExtensionAbility';
import rdb from '@ohos.data.rdb';
import fileIo from '@ohos.fileio'
import dataSharePredicates from '@ohos.data.dataSharePredicates'
import fileIo from '@ohos.fileio';
import dataSharePredicates from '@ohos.data.dataSharePredicates';
```
2. Override **DataShareExtensionAbility** APIs based on actual requirements. For example, if the data provider provides only data query, override only the **query()** API.
......@@ -80,7 +80,7 @@ Examples are given below.
}
// Override the query() API.
query(uri, predicates, columns, callback) {
query(uri, predicates, columns, callback) {
if (predicates == null || predicates == undefined) {
console.info('invalid predicates');
}
......@@ -144,48 +144,49 @@ Examples are given below.
let dseUri = ("datashare:///com.samples.datasharetest.DataShare");
```
2. Create a **DataShareHelper** instance.
3. Create a **DataShareHelper** instance.
```ts
let dsHelper;
let abilityContext;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
abilityContext = this.context;
dataShare.createDataShareHelper(abilityContext, dseUri, (err,data)=>{
dataShare.createDataShareHelper(abilityContext, dseUri, (err, data)=>{
dsHelper = data;
});
}
}
```
3. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data.
4. Use the APIs provided by **DataShareHelper** to access the services provided by the provider, for example, adding, deleting, modifying, and querying data.
```ts
// Construct a piece of data.
var valuesBucket = {"name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1,2,3])};
var updateBucket = {"name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1,2,3])};
let da = new dataSharePredicates.DataSharePredicates();
var valArray =new Array("*");
var valuesBucket = { "name": "ZhangSan", "age": 21, "isStudent": false, "Binary": new Uint8Array([1, 2, 3]) };
var updateBucket = { "name": "LiSi", "age": 18, "isStudent": true, "Binary": new Uint8Array([1, 2, 3]) };
let da = new dataSharePredicates.DataSharePredicates();
var valArray = new Array("*");
let people = new Array(
{"name": "LiSi", "age": 41, "Binary": ar},
{"name": "WangWu", "age": 21, "Binary": arr},
{"name": "ZhaoLiu", "age": 61, "Binary": arr});
{ "name": "LiSi", "age": 41, "Binary": ar },
{ "name": "WangWu", "age": 21, "Binary": arr },
{ "name": "ZhaoLiu", "age": 61, "Binary": arr });
// Insert a piece of data.
dsHelper.insert(dseUri, valuesBucket, (err,data) => {
console.log("dsHelper insert result: " + data);
dsHelper.insert(dseUri, valuesBucket, (err, data) => {
console.log("dsHelper insert result: " + data);
});
// Delete data.
dsHelper.delete(dseUri, da, (err,data) => {
console.log("dsHelper delete result: " + data);
dsHelper.delete(dseUri, da, (err, data) => {
console.log("dsHelper delete result: " + data);
});
// Update data.
dsHelper.update(dseUri, da, updateBucket, (err,data) => {
console.log("dsHelper update result: " + data);
dsHelper.update(dseUri, da, updateBucket, (err, data) => {
console.log("dsHelper update result: " + data);
});
// Query data.
dsHelper.query(dseUri, da, valArray, (err,data) => {
console.log("dsHelper query result: " + data);
dsHelper.query(dseUri, da, valArray, (err, data) => {
console.log("dsHelper query result: " + data);
});
```
......@@ -2,14 +2,13 @@
## When to Use
Distributed data objects allow data traversing across devices to be processed like local variables by shielding complex data interaction between devices. For the devices that form a Super Device, when data in the distributed data object of an application is added, deleted, or modified on a device, the data for the same application is also updated on the other devices. The devices can listen for data changes and online and offline status changes of other devices.
The distributed data objects support basic data types, such as number, string, and Boolean, as well as complex data types, such as array and nested basic types.
The **distributedDataObject** module provides APIs to implement data collaboration of the same application across multiple devices. In addition, the devices that form a Super Device can listen for object status and data changes with each other.
For example, when the data of the a distributed data object is added, deleted, or modified for application A on device 1, application A on device 2 can obtain the updated data. In addition, device 2 can listen for data changes and online/offline of the data objects on device 1.
## Available APIs
For details about the APIs related to the distributed data object, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md).
For details about the APIs, see [Distributed Data Object](../reference/apis/js-apis-data-distributedobject.md).
### Creating a Distributed Data Object Instance
......@@ -17,7 +16,7 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
| Package | API | Description |
| Package| API| Description|
| -------- | -------- | -------- |
| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.<br>- **source**: attributes of the **distributedObject** set.<br>- **DistributedObject**: returns the distributed object created.|
......@@ -26,35 +25,36 @@ Call **createDistributedObject()** to create a distributed data object instance.
Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object.
**Table 2** API for generating a session ID randomly
| Package | API | Description |
| Package| API| Description|
| -------- | -------- | -------- |
| ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.|
### Setting a SessionID for Distributed Data Objects
### Setting a SessionID for a Distributed Data Object
Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for distributed data objects.<br>**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for a distributed data object.<br>**sessionId**: session ID of a distributed object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes
Call **on()** to subscribe to data changes of a distributed data object. In the case of data change, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
Call **on()** to subscribe to data changes of a distributed data object. When the data changes, a callback will be invoked to return the data changes. You can use **off()** to unsubscribe from the data changes.
**Table 4** APIs for observing data changes of a distributed data object
| Class | API | Description |
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'change', callback: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Subscribes to data changes.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes.<br>**Callback**: specifies callback used to return changes of the distributed data object. If this parameter is not specified, all callbacks related to data changes will be unregistered.|
| DistributedDataObject| off(type: 'change', callback?: Callback<{ sessionId: string, fields: Array&lt;string&gt; }>): void | Unsubscribes from data changes. **Callback**: specifies the data changes to unsubscribe from. If this parameter is not specified, all data changes of this distributed data object will be unsubscribed from.|
### Observing Online or Offline Status
Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes.
**Table 5** APIs for observing status changes of a distributed data object
| Class | API | Description |
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.|
| DistributedDataObject| off(type: 'status', callback?: Callback<{ sessionId: string, deviceId: string, status: 'online' \| 'offline' }>): void | Unsubscribes from status changes of a distributed data object.|
......@@ -63,7 +63,7 @@ Call **on()** to subscribe to status changes of a distributed data object. The s
Call **save()** to save a distributed data object. When the application is active, the saved data will not be released. When the application exits and restarts, the data saved on the device will be restored.
Call **revokeSave()** to revoke a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device.
Call **revokeSave()** to delete a distributed data object that is no longer required. If the distributed data object is saved on the local device, **revokeSave()** will delete the data from all trusted devices. If the distributed data object is not saved on the local device, **revokeSave()** will delete the data from the local device.
The saved data will be released in the following cases:
......@@ -71,13 +71,11 @@ The saved data will be released in the following cases:
- The application has been uninstalled.
- Data is successfully restored.
**Table 6** APIs for saving a distributed data object and revoking the saving
| Class | API | Description |
**Table 6** APIs for saving a distributed data object and revoking the saving operation
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject | save(deviceId: string): Promise&lt;SaveSuccessResponse&gt; | Saves a distributed data object. This API uses a promise to return the result. |
| DistributedDataObject | save(deviceId: string, callback: AsyncCallback&lt;SaveSuccessResponse&gt;): void | Saves a distributed data object. This API uses an asynchronous callback to return the result. |
| DistributedDataObject | revokeSave(callback: AsyncCallback&lt;RevokeSaveSuccessResponse&gt;): void | Revokes the data saving operation. This API uses an asynchronous callback to return the result. |
| DistributedDataObject | revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt; | Revokes the data saving operation. This API uses a promise to return the result. |
| DistributedDataObject | save(deviceId: string): Promise&lt;SaveSuccessResponse&gt; | Saves a distributed data object.|
| DistributedDataObject| revokeSave(): Promise&lt;RevokeSaveSuccessResponse&gt; | Revokes the data saving operation.|
## How to Develop
......@@ -89,12 +87,14 @@ The following example shows how to implement distributed data object synchroniza
import distributedObject from '@ohos.data.distributedDataObject';
```
2. Request the permission.
2. Apply for the permission.
Add the required permission (FA model) in the **config.json** file.
The sample code is as follows:
Add the required permission in the **config.json** file. The sample code is as follows:
```
{
```json
{
"module": {
"reqPermissions": [
{
......@@ -103,106 +103,125 @@ The following example shows how to implement distributed data object synchroniza
]
}
}
```
This permission must also be authorized by the user through a dialog box when the application is started for the first time. The sample code is as follows:
```
```
For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model).
This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
```json
import featureAbility from '@ohos.ability.featureAbility';
function grantPermission() {
console.info('grantPermission');
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
console.info('end grantPermission');
}
grantPermission();
```
function grantPermission() {
console.info('grantPermission');
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
console.info('end grantPermission');
}
grantPermission();
```
3. Obtain a distributed data object instance.
The sample code is as follows:
```js
var local_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined});
var local_object = distributedObject.createDistributedObject({
name: undefined,
age: undefined,
isVis: true,
parent: undefined,
list: undefined
});
var sessionId = distributedObject.genSessionId();
```
4. Add the synchronization network. The data objects in the synchronization network include the local and remote objects.
4. Add the distributed data object instance to the synchronization network.
The sample code is as follows:
The data objects in the synchronization network include the local and remote objects.
The sample code is as follows:
```js
// Local object
var local_object = distributedObject.createDistributedObject({name:"jack", age:18, isVis:true,
parent:{mother:"jack mom", father:"jack Dad"}, list:[{mother:"jack mom"}, {father:"jack Dad"}]});
var local_object = distributedObject.createDistributedObject({
name: "jack",
age: 18,
isVis: true,
parent: { mother: "jack mom", father: "jack Dad" },
list: [{ mother: "jack mom" }, { father: "jack Dad" }]
});
local_object.setSessionId(sessionId);
// Remote object
var remote_object = distributedObject.createDistributedObject({name:undefined, age:undefined, isVis:true,
parent:undefined, list:undefined});
remote_object.setSessionId(sessionId);
var remote_object = distributedObject.createDistributedObject({
name: undefined,
age: undefined,
isVis: true,
parent: undefined,
list: undefined
});
// After learning that the device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
remote_object.setSessionId(sessionId);
```
5. Observe the data changes of the distributed data object.
You can subscribe to data changes of the peer object. When the data in the peer object changes, a callback will be called to return the data changes.
You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
The sample code is as follows:
```js
function changeCallback(sessionId, changeData) {
console.info("change" + sessionId);
console.info("change" + sessionId);
if (changeData != null && changeData != undefined) {
changeData.forEach(element => {
console.info("changed !" + element + " " + local_object[element]);
});
}
}
if (changeData != null && changeData != undefined) {
changeData.forEach(element => {
console.info("changed !" + element + " " + local_object[element]);
});
}
}
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this));
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
local_object.on("change", this.changeCallback.bind(this));
```
6. Modify object attributes.
6. Modify attributes of the distributed data object.
The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
The sample code is as follows:
```js
local_object.name = "jack";
local_object.age = 19;
local_object.isVis = false;
local_object.parent = {mother:"jack mom", father:"jack Dad"};
local_object.list = [{mother:"jack mom"}, {father:"jack Dad"}];
local_object.parent = { mother: "jack mom", father: "jack Dad" };
local_object.list = [{ mother: "jack mom" }, { father: "jack Dad" }];
```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified.
Example:
> **NOTE**<br>
> For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
```js
// Supported modification.
local_object.parent = {mother:"mom", father:"dad"};
local_object.parent = { mother: "mom", father: "dad" };
// Modification not supported.
local_object.parent.mother = "mom";
```
7. Access the distributed data object.
Obtain the distributed data object attribute, which is the latest data on the network.
Obtain the distributed data object attributes, which are the latest data on the network.
The sample code is as follows:
```js
console.info("name " + local_object["name"]);
```
......@@ -221,7 +240,6 @@ The following example shows how to implement distributed data object synchroniza
```
9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
The sample code is as follows:
```js
......@@ -234,53 +252,29 @@ The following example shows how to implement distributed data object synchroniza
10. Save a distributed data object and revoke the data saving operation.
- Callback
```
​```js
// Save a distributed data object.
local_object.save("local", (result, data) => {
console.log("save callback");
console.info("save sessionId " + data.sessionId);
console.info("save version " + data.version);
console.info("save deviceId " + data.deviceId);
});
// Revoke the data saving operation.
local_object.revokeSave((result, data) => {
console.log("revokeSave callback");
console.info("revokeSave sessionId " + data.sessionId);
});
​```
```
- Promise
```
​```js
// Save a distributed data object.
g_object.save("local").then((result) => {
console.info("save sessionId " + result.sessionId);
console.info("save version " + result.version);
console.info("save deviceId " + result.deviceId);
}, (result)=>{
console.info("save local failed.");
});
// Revoke the data saving operation.
g_object.revokeSave().then((result) => {
console.info("revokeSave success.");
}, (result)=>{
console.info("revokeSave failed.");
});
​```
```
```js
// Save a distributed data object.
g_object.save("local").then((result) => {
console.info("save sessionId " + result.sessionId);
console.info("save version " + result.version);
console.info("save deviceId " + result.deviceId);
}, (result) => {
console.info("save local failed.");
});
// Revoke the data saving operation.
g_object.revokeSave().then((result) => {
console.info("revokeSave success.");
}, (result) => {
console.info("revokeSave failed.");
});
```
11. Unsubscribe from the status changes of the distributed data object.
You can specify the callback to unregister. If you do not specify the callback, this API unregisters all callbacks of this distributed data object.
You can specify the callback to unregister. If you do not specify the callback, this API unregisters all status change callbacks of this distributed data object.
The sample code is as follows:
```js
// Unregister the specified status change callback.
local_object.off("status", this.statusCallback);
......@@ -288,9 +282,12 @@ The following example shows how to implement distributed data object synchroniza
local_object.off("status");
```
12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
12. Remove a distributed data object from the synchronization network.
The sample code is as follows:
```js
local_object.setSessionId("");
```
Data changes on the local object will not be synchronized to the removed distributed data object.
The sample code is as follows:
```js
local_object.setSessionId("");
```
# Distributed Data Object Overview
The distributed data object management framework is an object-oriented in-memory data management framework. It provides application developers with basic data object management capabilities, such as creating, querying, deleting, modifying, and subscribing to in-memory objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device.
The distributed data object management framework provides object-oriented in-memory data management. It provides basic data management capabilities, such as creating, querying, deleting, and modifying distributed data objects, and observing data and status changes of the distributed data objects. This management framework also provides distributed capabilities to implement data object collaboration for the same application between multiple devices that form a Super Device.
## Key Concepts
## Basic Concepts
- **Distributed in-memory database**
The distributed in-memory database caches data in the memory, so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained.
The distributed in-memory database caches data in the memory so that applications can quickly access data. This database, however, does not store data persistently. If the database is closed, the data is not retained.
- **Distributed data object**
A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading or assigning values to distributed data objects is automatically mapped to the **put** or **get** operation of the corresponding database.
A distributed data object is an encapsulation of the JS object type. Each distributed data object instance creates a data table in the in-memory database. The in-memory databases created for different applications are isolated from each other. Reading data from and writing data to a distributed data object are mapped to the **put** and **get** operations in the corresponding database, respectively.
The distributed data object can be in the following states in its lifecycle:
- **Uninitialized**: The distributed data object is not instantiated or has been destroyed.
- **Local**: The data table is created, but the data cannot be synchronized.
- **Distributed**: The data table is created, there are at least two online with the same session ID, and data can be synchronized across devices. If the device is offline or the session ID is empty, the distributed data object changes to the local state.
- **Distributed**: The data table is created, and there are at least two online devices with the same session ID. In this case, data can be synchronized across devices. If a device is offline or the session ID is empty, the distributed data object changes to the local state.
## Working Principles
The distributed data objects are encapsulated into JS objects in distributed in-memory databases, which allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization.
The distributed data objects are encapsulated into JS objects in distributed in-memory databases. This allows the distributed data objects to be operated in the same way as local variables. The system automatically implements cross-device data synchronization.
**Figure 1** Working mechanism
......@@ -34,7 +34,7 @@ The distributed data objects are encapsulated into JS objects in distributed in-
## Constraints
- Data synchronization can be implemented across devices only for the applications with the same bundleName.
- Data synchronization can be implemented across devices only for the applications with the same **bundleName**.
- Each distributed data object occupies 100 KB to 150 KB of memory. Therefore, you are advised not to create too many distributed data objects.
......
......@@ -6,113 +6,144 @@ 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).
For details about the APIs, see [Distributed Data Management](../reference/apis/js-apis-distributed-data.md).
**Table 1** APIs provided by the DDS
| 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. |
| 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. |
## How to Develop
The following uses a single KV store as an example to describe the development procedure.
1. Import the distributed data module.
```js
import distributedData from '@ohos.data.distributedData';
```
2. Apply for the required permission if data synchronization is required.
2. Create a **KvManager** instance based on the specified **KvManagerConfig** object.
(1) Create a **KvManagerConfig** object based on the application context.
Add the permission required (FA model) in the **config.json** file. The sample code is as follows:
```json
{
"module": {
"reqPermissions": [
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
]
}
}
```
For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model).
This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
```js
import featureAbility from '@ohos.ability.featureAbility';
function grantPermission() {
console.info('grantPermission');
let context = featureAbility.getContext();
context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
console.info(`result.requestCode=${result.requestCode}`)
})
console.info('end grantPermission');
}
grantPermission();
```
3. 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.
(2) Create a **KvManager** instance.
The sample code is as follows:
```
```js
let kvManager;
try {
const kvManagerConfig = {
bundleName : 'com.example.datamanagertest',
userInfo : {
userId : '0',
userType : distributedData.UserType.SAME_USER_ID
}
const kvManagerConfig = {
bundleName: 'com.example.datamanagertest',
userInfo: {
userId: '0',
userType: distributedData.UserType.SAME_USER_ID
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("createKVManager err: " + JSON.stringify(err));
return;
}
console.log("createKVManager success");
kvManager = manager;
});
}
distributedData.createKVManager(kvManagerConfig, function (err, manager) {
if (err) {
console.log("createKVManager err: " + JSON.stringify(err));
return;
}
console.log("createKVManager success");
kvManager = manager;
});
} catch (e) {
console.log("An unexpected error occurred. Error:" + e);
console.log("An unexpected error occurred. Error: " + e);
}
```
3. Create and obtain a single KV store.
(1) Declare the ID of the single KV store to create.
4. Create and obtain a single KV store.
(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
let kvStore;
try {
const options = {
createIfMissing : true,
encrypt : false,
backup : false,
autoSync : false,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
securityLevel : distributedData.SecurityLevel.S0,
};
kvManager.getKVStore('storeId', options, function (err, store) {
if (err) {
console.log("getKVStore err: " + JSON.stringify(err));
return;
}
console.log("getKVStore success");
kvStore = store;
});
const options = {
createIfMissing: true,
encrypt: false,
backup: false,
autoSync: false,
kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
securityLevel: distributedData.SecurityLevel.S0
};
kvManager.getKVStore('storeId', options, function (err, store) {
if (err) {
console.log("getKVStore err: " + JSON.stringify(err));
return;
}
console.log("getKVStore success");
kvStore = store;
});
} catch (e) {
console.log("An unexpected error occurred. Error:" + e);
console.log("An unexpected error occurred. Error: " + e);
}
```
> **NOTE**
> **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.
5. Subscribe to changes in the distributed data.
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:
```js
kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.log("dataChange callback call data: " + JSON.stringify(data));
});
```
5. Write data to the single KV store.
(1) Construct the key and value to be written into the single KV store.
6. Write data to 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:
......@@ -120,52 +151,54 @@ The following uses a single KV store as an example to describe the development p
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
return;
}
console.log("put success");
});
}catch (e) {
console.log("An unexpected error occurred. Error:" + e);
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
}
```
6. Query data in the single KV store.
(1) Construct the key to be queried from the single KV store.
7. Query data in 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
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value-test-string';
try {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) {
kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err, data) {
if (err != undefined) {
console.log("put err: " + JSON.stringify(err));
return;
}
console.log("put success");
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) {
kvStore.get(KEY_TEST_STRING_ELEMENT, function (err, data) {
console.log("get success data: " + data);
});
});
}catch (e) {
console.log("An unexpected error occurred. Error:" + e);
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
}
```
7. Synchronize data to other devices.<br/>
8. Synchronize data to other devices.
Select the devices in the same network and the synchronization mode to synchronize data.
> **NOTE**
> **NOTE**<br>
>
> The APIs of the `deviceManager` module are system interfaces.
The following is the example code for synchronizing data in a single KV store:
The following is the sample code for synchronizing data in a single KV store:
```js
import deviceManager from '@ohos.distributedHardware.deviceManager';
......@@ -185,8 +218,8 @@ 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);
} catch (e) {
console.log("An unexpected error occurred. Error: " + e);
}
}
});
......
......@@ -2,7 +2,7 @@
> **NOTE**
>
> This feature is supported since API Version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs.
> This feature is supported since API version 9. For the versions earlier than API version 9, use [Lightweight Storage](../reference/apis/js-apis-data-storage.md) APIs.
## When to Use
......@@ -88,8 +88,30 @@ Use the following APIs to delete a **Preferences** instance or data file.
2. Obtain a **Preferences** instance.
Read the specified file and load its data to the **Preferences** instance for data operations.
FA model:
```js
let promise = data_preferences.getPreferences(this.context, 'mystore');
// Obtain the context.
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
let promise = data_preferences.getPreferences(context, 'mystore');
```
Stage model:
```ts
// Obtain the context.
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
let promise = data_preferences.getPreferences(context, 'mystore');
```
3. Write data.
......@@ -115,12 +137,12 @@ Use the following APIs to delete a **Preferences** instance or data file.
```js
promise.then((preferences) => {
let getPromise = preferences.get('startup', 'default');
getPromise.then((value) => {
console.info("The value of 'startup' is " + value);
}).catch((err) => {
console.info("Failed to get the value of 'startup'. Cause: " + err);
})
let getPromise = preferences.get('startup', 'default');
getPromise.then((value) => {
console.info("The value of 'startup' is " + value);
}).catch((err) => {
console.info("Failed to get the value of 'startup'. Cause: " + err);
})
}).catch((err) => {
console.info("Failed to get the preferences.")
});
......@@ -139,24 +161,24 @@ Use the following APIs to delete a **Preferences** instance or data file.
Specify an observer as the callback to subscribe to data changes for an application. When the value of the subscribed key is changed and saved by **flush()**, the observer callback will be invoked to return the new data.
```js
var observer = function (key) {
console.info("The key" + key + " changed.");
}
preferences.on('change', observer);
preferences.put('startup', 'auto', function (err) {
if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err);
return;
}
var observer = function (key) {
console.info("The key" + key + " changed.");
}
preferences.on('change', observer);
preferences.put('startup', 'auto', function (err) {
if (err) {
console.info("Failed to put the value of 'startup'. Cause: " + err);
return;
}
console.info("Put the value of 'startup' successfully.");
preferences.flush(function (err) {
if (err) {
console.info("Failed to flush data. Cause: " + err);
return;
}
preferences.flush(function (err) {
if (err) {
console.info("Failed to flush data. Cause: " + err);
return;
}
console.info("Flushed data successfully."); // The observer will be called.
})
})
})
})
```
7. Delete the specified file.
......@@ -164,10 +186,10 @@ Use the following APIs to delete a **Preferences** instance or data file.
Use the **deletePreferences** method to delete the **Preferences** instance and its persistent file and backup and corrupted files. After the specified files are deleted, the application cannot use that instance to perform any data operation. Otherwise, data inconsistency will be caused. The deleted data and files cannot be restored.
```js
let proDelete = data_preferences.deletePreferences(context, 'mystore');
proDelete.then(() => {
let proDelete = data_preferences.deletePreferences(context, 'mystore');
proDelete.then(() => {
console.info("Deleted data successfully.");
}).catch((err) => {
}).catch((err) => {
console.info("Failed to delete data. Cause: " + err);
})
})
```
......@@ -30,9 +30,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 2** API for inserting data
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | insert(table:string,values:ValuesBucket):Promise&lt;number&gt; | Inserts a row of data into a table. This API uses a promise to return the result.<br>If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.<br>- **table**: name of the target table.<br>- **values**: data to be inserted into the table.|
| RdbStore | insert(table: string, values: ValuesBucket): Promise&lt;number&gt; | Inserts a row of data into a table. This API uses a promise to return the result.<br>If the operation is successful, the row ID will be returned; otherwise, **-1** will be returned.<br>- **table**: name of the target table.<br>- **values**: data to be inserted into the table.|
- **Updating Data**
......@@ -40,9 +41,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 3** API for updating data
| Class | API | Description |
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | update(values:ValuesBucket,predicates:RdbPredicates):Promise&lt;number&gt; | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.<br/>- **values**: data to update, which is stored in **ValuesBucket**.<br>- **predicates**: conditions for updating data.<br/>Return value: number of rows updated. |
| RdbStore | update(values: ValuesBucket, predicates: RdbPredicates): Promise&lt;number&gt; | Updates data based on the specified **RdbPredicates** object. This API uses a promise to return the result.<br>the number of rows updated.<br>- **values**: data to update, which is stored in **ValuesBucket**.<br>- **predicates**: conditions for updating data.|
- **Deleting Data**
......@@ -50,11 +52,10 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 4** API for deleting data
| Class | API | Description |
| -------- | ------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | delete(predicates:RdbPredicates):Promise&lt;number&gt; | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.<br>- **predicates**: conditions for deleting data.<br/>Return value: number of rows updated. |
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | delete(predicates: RdbPredicates): Promise&lt;number&gt; | Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return<br>the number of rows updated.<br>- **predicates**: conditions for deleting data.|
- **Querying Data**
......@@ -65,10 +66,11 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
**Table 5** APIs for querying data
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | query(predicates:RdbPredicates,columns?:Array&lt;string&gt;):Promise&lt;ResultSet&gt; | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.<br>- **predicates**: conditions for querying data.<br>- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
| RdbStore | querySql(sql:string,bindArgs?:Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; | Queries data using the specified SQL statement. This API uses a promise to return the result.<br>- **sql**: SQL statement.<br>- **bindArgs**: arguments in the SQL statement.|
| RdbStore | query(predicates: RdbPredicates, columns?: Array&lt;string&gt;): Promise&lt;ResultSet&gt; | Queries data from the RDB store based on specified conditions. This API uses a promise to return the result.<br>- **predicates**: conditions for querying data.<br>- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
| RdbStore | querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;): Promise&lt;ResultSet&gt; | Queries data using the specified SQL statement. This API uses a promise to return the result.<br>- **sql**: SQL statement.<br>- **bindArgs**: arguments in the SQL statement.|
| RdbStore | remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt;): Promise&lt;ResultSet&gt; | Queries data from the database of a remote device based on specified conditions. This API uses a promise to return the result.<br>- **device**: network ID of the remote device.<br>- **table**: name of the table to be queried.<br>- **predicates**: **RdbPredicates** that specifies the query condition.<br>- **columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
### Using Predicates
......@@ -81,11 +83,11 @@ The following lists common predicates. For more information about predicates, se
| Class | API | Description |
| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbPredicates | equalTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
| RdbPredicates | notEqualTo(field:string,value:ValueType):RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
| RdbPredicates | or():RdbPredicates | Adds the OR condition to the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** with the OR condition.|
| RdbPredicates | and():RdbPredicates | Adds the AND condition to the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** with the AND condition.|
| RdbPredicates | contains(field:string,value:string):RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | Sets an **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
| RdbPredicates | or(): RdbPredicates | Adds the OR condition to the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** with the OR condition.|
| RdbPredicates | and(): RdbPredicates | Adds the AND condition to the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** with the AND condition.|
| RdbPredicates | contains(field: string, value: string): RdbPredicates | Sets an **RdbPredicates** to match a string containing the specified value.<br>- **field**: column name in the database table.<br>- **value**: value to match the **RdbPredicates**.<br>- **RdbPredicates**: **RdbPredicates** object that matches the specified field.|
### Using the Result Set
......@@ -101,12 +103,12 @@ For details about how to use result set APIs, see [Result Set](../reference/apis
| Class | API | Description |
| --------- | ---------------------------------------------------- | ------------------------------------------ |
| ResultSet | goToFirstRow():boolean | Moves to the first row of the result set. |
| ResultSet | getString(columnIndex:number):string | Obtains the value in the form of a string based on the specified column and current row. |
| ResultSet | getBlob(columnIndex:number):Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
| ResultSet | getDouble(columnIndex:number):number | Obtains the value in the form of double based on the specified column and current row. |
| ResultSet | getLong(columnIndex:number):number | Obtains the value in the form of a long integer based on the specified column and current row. |
| ResultSet | close():void | Closes the result set. |
| ResultSet | goToFirstRow(): boolean | Moves to the first row of the result set. |
| ResultSet | getString(columnIndex: number): string | Obtains the value in the form of a string based on the specified column and current row. |
| ResultSet | getBlob(columnIndex: number): Uint8Array | Obtains the value in the form of a byte array based on the specified column and the current row.|
| ResultSet | getDouble(columnIndex: number): number | Obtains the value in the form of double based on the specified column and current row. |
| ResultSet | getLong(columnIndex: number): number | Obtains the value in the form of a long integer based on the specified column and current row. |
| ResultSet | close(): void | Closes the result set. |
......@@ -164,7 +166,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | backup(destName:string): Promise&lt;void&gt; | Backs up an RDB store. This API uses a promise to return the result.<br>- **destName**: name of the RDB backup file.|
| RdbStore | backup(destName: string): Promise&lt;void&gt; | Backs up an RDB store. This API uses a promise to return the result.<br>- **destName**: name of the RDB backup file.|
**Restoring an RDB Store**
......@@ -172,7 +174,7 @@ You can obtain the distributed table name for a remote device based on the local
| Class | API | Description |
| -------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| RdbStore | restore(srcName:string): Promise&lt;void&gt; | Restores an RDB store from a backup file. This API uses a promise to return the result.<br>- **srcName**: name of the backup file used to restore the RDB store.|
| RdbStore | restore(srcName: string): Promise&lt;void&gt; | Restores an RDB store from a backup file. This API uses a promise to return the result.<br>- **srcName**: name of the backup file used to restore the RDB store.|
**Transaction**
......@@ -180,9 +182,9 @@ Table 15 Transaction APIs
| Class | API | Description |
| -------- | ----------------------- | --------------------------------- |
| RdbStore | beginTransaction():void | Starts the transaction before executing SQL statements.|
| RdbStore | commit():void | Commits the executed SQL statements. |
| RdbStore | rollBack():void | Rolls back the SQL statements that have been executed. |
| RdbStore | beginTransaction(): void | Starts the transaction before executing SQL statements.|
| RdbStore | commit(): void | Commits the executed SQL statements. |
| RdbStore | rollBack(): void | Rolls back the SQL statements that have been executed. |
## How to Develop
......@@ -200,10 +202,10 @@ Table 15 Transaction APIs
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(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
rdbStore.executeSql(CREATE_TABLE_TEST)
console.info('create table done.')
})
```
......@@ -217,7 +219,7 @@ Table 15 Transaction APIs
```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)
```
......@@ -316,6 +318,7 @@ Table 15 Transaction APIs
console.log('device=' + device[i] + 'data changed')
}
}
try {
rdbStore.on('dataChange', data_rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
} catch (err) {
......@@ -366,9 +369,7 @@ Table 15 Transaction APIs
(1) Back up the current RDB store.
(2) Restore the RDB store using the backup file.
The sample code is as follows:
The sample code is as follows:
```js
let promiseBackup = rdbStore.backup("dbBackup.db")
......@@ -378,6 +379,10 @@ Table 15 Transaction APIs
console.info('Backup failed, err: ' + err)
})
```
(2) Restore the RDB store using the backup file.
The sample code is as follows:
```js
let promiseRestore = rdbStore.restore("dbBackup.db")
promiseRestore.then(() => {
......@@ -386,4 +391,3 @@ Table 15 Transaction APIs
console.info('Restore failed, err: ' + err)
})
```
......@@ -23,4 +23,4 @@ The vibrator is a Misc device that consists of four modules: Vibrator API, Vibra
## Constraints
When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The sensitivity level of this permission is **system_grant**.
When using a vibrator, you must declare the **ohos.permission.VIBRATE** permission before you can control the vibration effect. The authorization mode of this permission is **system_grant**.
......@@ -54,7 +54,7 @@ await cameraManager.getCameras((err, cameras) => {
cameraArray = cameras
})
for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex) {
for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) {
console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // Obtain the camera ID.
console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // Obtain the camera position.
console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // Obtain the camera type.
......
......@@ -25,56 +25,25 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
## WindowExtensionAbility.onConnect
onConnect(want: Want): rpc.RemoteObject
onConnect(want: Want): void
Called when this Window Extension ability is connected to an ability for the first time.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. |
**Return value**
| Type | Description |
| ----------------------------------------------- | -------------------- |
| [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Proxy of this Window Extension ability.|
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
```ts
import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
return true;
}
queryLocalInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
sendRequest(code, data, reply, options) {
return null;
}
getCallingPid() {
return 1;
}
getCallingUid() {
return 1;
}
attachLocalInterface(localInterface, descriptor){}
}
export default class MyWindowExtensionAbility extends WindowExtensionAbility {
onConnect(want): rpc.RemoteObject {
onConnect(want) {
console.info('WindowExtAbility onConnect ' + want.abilityName);
return new StubTest("test");
}
}
......@@ -88,9 +57,11 @@ Called when this Window Extension ability is disconnected from all connected abi
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name. |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example**
......@@ -105,7 +76,6 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
}
```
## WindowExtensionAbility.onWindowReady
onWindowReady(window: Window): void
......@@ -114,6 +84,8 @@ Called when a window is ready.
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| window | [Window](js-apis-window.md) | Yes| Current **Window** instance.|
......
......@@ -119,6 +119,25 @@ Subscribes to device connection events. This API uses an asynchronous callback t
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceconnect9) instead.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
**Example**
```js
continuationManager.on("deviceConnect", (data) => {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
});
```
## continuationManager.on("deviceDisconnect")<sup>(deprecated)</sup>
on(type: "deviceDisconnect", callback: Callback\<string>): void;
......@@ -127,6 +146,23 @@ Subscribes to device disconnection events. This API uses an asynchronous callbac
> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondevicedisconnect9) instead.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| callback | Callback\<string> | Yes| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.|
**Example**
```js
continuationManager.on("deviceDisconnect", (data) => {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
});
```
## continuationManager.off("deviceConnect")<sup>(deprecated)</sup>
off(type: "deviceConnect", callback?: Callback\<ContinuationResult>): void;
......@@ -135,6 +171,25 @@ Unsubscribes from device connection events. This API uses an asynchronous callba
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceconnect9) instead.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
| callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | No| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
**Example**
```js
continuationManager.off("deviceConnect", (data) => {
console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
});
```
## continuationManager.off("deviceDisconnect")<sup>(deprecated)</sup>
off(type: "deviceDisconnect", callback?: Callback\<string>): void;
......@@ -143,6 +198,23 @@ Unsubscribes from device disconnection events. This API uses an asynchronous cal
> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdevicedisconnect9) instead.
**System capability**: SystemCapability.Ability.DistributedAbilityManager
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
| callback | Callback\<string> | No| Callback invoked when a device is disconnected in the device selection module. This callback returns the device ID.|
**Example**
```js
continuationManager.off("deviceDisconnect", (data) => {
console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
});
```
## continuationManager.on("deviceConnect")<sup>9+</sup>
on(type: "deviceConnect", token: number, callback: Callback\<Array\<ContinuationResult>>): void;
......
......@@ -55,8 +55,8 @@ let options = {trim : false, declarationKey:"_declaration",
commentKey : "_comment", parentKey : "_parent", typeKey : "_type",
nameKey : "_name", elementsKey : "_elements"}
let result = JSON.stringify(conv.convert(xml, options));
console.log(result)
// Output(Non compact)
console.log(result);
// Output (non-compact)
// {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}
```
......
......@@ -1529,9 +1529,9 @@ Queries data from the RDB store of a remote device based on specified conditions
**Example**
```js
let predicates = new rdb.RdbPredicates('EPLOYEE')
let predicates = new rdb.RdbPredicates('EMPLOYEE')
predicates.greaterThan("id", 0)
rdbStore.remoteQuery("deviceId", "EPLOYEE", predicates, function(err, resultSet){
rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates, function(err, resultSet){
if (err) {
console.info("Failed to remoteQuery, err: " + err)
return
......@@ -1567,7 +1567,7 @@ Queries data from the RDB store of a remote device based on specified conditions
**Example**
```js
let predicates = new rdb.RdbPredicates('EPLOYEE')
let predicates = new rdb.RdbPredicates('EMPLOYEE')
predicates.greaterThan("id", 0)
let promise = rdbStore.remoteQuery("deviceId", "EMPLOYEE", predicates)
promise.then((resultSet) => {
......
......@@ -55,7 +55,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
let storage = data_storage.getStorageSync(path + '/mystore');
......@@ -88,7 +88,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
data_storage.getStorage(path + '/mystore', function (err, storage) {
......@@ -131,7 +131,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
let getPromise = data_storage.getStorage(path + '/mystore');
......@@ -167,7 +167,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
data_storage.deleteStorageSync(path + '/mystore');
......@@ -198,7 +198,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
data_storage.deleteStorage(path + '/mystore', function (err) {
......@@ -239,7 +239,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
let promisedelSt = data_storage.deleteStorage(path + '/mystore');
......@@ -274,7 +274,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
data_storage.removeStorageFromCacheSync(path + '/mystore');
......@@ -305,7 +305,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
data_storage.removeStorageFromCache(path + '/mystore', function (err) {
......@@ -347,7 +347,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
});
let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore')
......
......@@ -67,7 +67,7 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi
| Type | Description |
| ---------------------- | -------------- |
| Promisse\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.|
| Promise\<[ColorPicker](#colorpicker)> | Promise used to return the **ColorPicker** instance created.|
**Example**
......
......@@ -21,28 +21,31 @@ Shows a toast.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------------------------------------- | ---- | ------- |
| options | [ShowToastOptions](#showtoastoptions) | Yes | Toast options.|
**Example**
```js
```js
prompt.showToast({
message: 'Message Info',
duration: 2000,
});
```
```
## ShowToastOptions
Describes the options for showing the toast.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ------ | ---------------------------------------- |
| message | string\| [Resource](.../ui/ts-types.md#resource-type)<sup>9+</sup>| Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
| bottom | string\| number | No | Distance between the toast border and the bottom of the screen. |
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| message | string\| [Resource](.../ui/ts-types.md#resource-type)<sup>9+</sup>| Yes | Text to display. |
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used. If the value greater than 10000 ms is set, the upper limit 10000 ms is used.|
| bottom | string\| number | No | Distance between the toast border and the bottom of the screen. |
## prompt.showDialog
......@@ -53,6 +56,7 @@ Shows a dialog box. This API uses a promise to return the result synchronously.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | --------------------------------------- | ---- | ------ |
| options | [ShowDialogOptions](#showdialogoptions) | Yes | Dialog box options.|
......@@ -65,7 +69,7 @@ Shows a dialog box. This API uses a promise to return the result synchronously.
**Example**
```js
```js
prompt.showDialog({
title: 'Title Info',
message: 'Message Info',
......@@ -86,7 +90,7 @@ prompt.showDialog({
.catch(err => {
console.info('showDialog error: ' + err);
})
```
```
## prompt.showDialog
......@@ -96,15 +100,16 @@ Shows a dialog box. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ------------ |
| options | [ShowDialogOptions](#showdialogoptions) | Yes | Dialog box options.|
| callback | AsyncCallback&lt;[ShowDialogSuccessResponse](#showdialogsuccessresponse)&gt; | Yes | Callback used to return the dialog box response result. |
**Example**
```js
```js
prompt.showDialog({
title: 'showDialog Title Info',
message: 'Message Info',
......@@ -125,7 +130,7 @@ prompt.showDialog({
}
console.info('showDialog success callback, click button: ' + data.index);
});
```
```
## ShowDialogOptions
......@@ -159,6 +164,7 @@ Shows an action menu. This API uses a callback to return the result asynchronous
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | --------- |
| options | [ActionMenuOptions](#actionmenuoptions) | Yes | Action menu options. |
......@@ -166,7 +172,8 @@ Shows an action menu. This API uses a callback to return the result asynchronous
**Example**
```js
```js
prompt.showActionMenu({
title: 'Title Info',
buttons: [
......@@ -186,7 +193,7 @@ prompt.showActionMenu({
}
console.info('showActionMenu success callback, click button: ' + data.index);
})
```
```
## prompt.showActionMenu
......@@ -197,17 +204,20 @@ Shows an action menu. This API uses a promise to return the result synchronously
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | --------------------------------------- | ---- | ------- |
| options | [ActionMenuOptions](#actionmenuoptions) | Yes | Action menu options.|
**Return value**
| Type | Description |
| ---------------------------------------- | ------- |
| Promise&lt;[ActionMenuSuccessResponse](#actionmenusuccessresponse)&gt; | Promise used to return the action menu response result.|
**Example**
```js
```js
prompt.showActionMenu({
title: 'showActionMenu Title Info',
buttons: [
......@@ -227,7 +237,7 @@ prompt.showActionMenu({
.catch(err => {
console.info('showActionMenu error: ' + err);
})
```
```
## ActionMenuOptions
Describes the options for showing the action menu.
......
......@@ -99,7 +99,7 @@ Unsubscribes from events related to the screen state.
**Example**
```js
var callback = (data) => {
console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data))
console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data))
};
screen.off("connect", callback);
```
......
......@@ -3122,7 +3122,7 @@ let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
promise.then((data)=> {
console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err));
console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
});
```
......
......@@ -357,9 +357,9 @@ that.parse(options);
console.log(str);
// Output:
// key:0 value:0key:2 value:1key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:3 value:1key:1 value:0
// Notes:
// The key represents the current event type, and the value represents the depth of the current parsing. You can know the parsed event according to EVENTTYPE. For example, the result 'key: value' in this example means:
// 0(START_DOCUMENT):0(Parse to the START_DOCUMENT, and the depth is 0), 2(START_TAG):1(Parse to the START_TAG node, and the depth is 1), 10(WHITESPACE):1(Parse to the WHITESPACE space, and the depth is 1), 2(START_TAG):2(Parse to the START_TAG title, and the depth is 2), ...
// Note:
// key indicates the event type, and value indicates the parsing depth. You can learn the specific parsed event based on EVENTTYPE. In this example, key: value means:
// 0(START_DOCUMENT):0 (START_DOCUMENT is being parsed, and the depth is 0), 2(START_TAG):1 (START_TAG is being parsed, and the depth is 1), 10(WHITESPACE):1 (WHITESPACE is being parsed, and the depth is 1), 2(START_TAG):2 (START_TAG is being parsed, and the depth is 2), ...
```
......
......@@ -182,7 +182,7 @@ To create a better video watching and gaming experience, you can use the immersi
- Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
- Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar.
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemPropertites` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
```js
// 2. Use method 1 to implement the immersive effect.
......
......@@ -216,7 +216,7 @@ To create a better video watching and gaming experience, you can use the immersi
2. Implement the immersive effect. You can use any of the following methods:
- Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
- Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar.
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemPropertites` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
3. Load content for the immersive window and show it.
......
......@@ -34,7 +34,7 @@ In addition, OpenHarmony provides a wide array of system components that can be
| About OpenHarmony| Getting familiar with OpenHarmony | - [About OpenHarmony](https://gitee.com/openharmony)<br>- [Glossary](../glossary.md)|
| Development resources | Preparing for your development | - [Obtaining Source Code](get-code/sourcecode-acquire.md)<br>- [Obtaining Tools](get-code/gettools-acquire.md) |
| Getting started | Getting started with setup, build, burning, debugging, and running of OpenHarmony | - [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md)|
| Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Mini System](kernel/kernel-mini-overview.md)<br>- [Kernel for Small System](kernel/kernel-small-overview.md)<br>- [HDF](driver/driver-hdf-overview.md)<br>- [Subsystems](subsystems/subsys-build-mini-lite.md)<br>- [Security Guidelines](security/security-guidelines-overall.md)<br>- [Privacy Protection](security/security-privacy-protection.md)|
| Basic capabilities | Using basic capabilities of OpenHarmony | - [Kernel for Mini System](kernel/kernel-mini-overview.md)<br>- [Kernel for Small System](kernel/kernel-small-overview.md)<br>- [HDF](driver/driver-hdf-overview.md)<br>- [Subsystems](subsystems/subsys-build-all.md)<br>- [Security Guidelines](security/security-guidelines-overall.md)<br>- [Privacy Protection](security/security-privacy-protection.md) |
| Advanced development | Developing smart devices based on system capabilities | - [WLAN-connected Products](guide/device-wlan-led-control.md)<br>- [Cameras Without a Screen](guide/device-iotcamera-control-overview.md)<br>- [Cameras with a Screen](guide/device-camera-control-overview.md) |
| Porting and adaptation | - Porting and adapting OpenHarmony to an SoC<br>- Porting and adapting OpenHarmony to a third-party library<br>- Third-party vendor porting cases<br>| - [Mini System SoC Porting Guide](porting/porting-minichip.md)<br>- [Small System SoC Porting Guide](porting/porting-smallchip-prepare-needs.md)<br>- [Third-Party Library Porting Guide for Mini and Small Systems](porting/porting-thirdparty-overview.md) <br> - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md)<br> - [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)<br> |
| Contributing components | Contributing components to OpenHarmony | - [HPM Part Overview](hpm-part/hpm-part-about.md)<br>- [HPM Part Development](hpm-part/hpm-part-development.md)<br>- [HPM Part Reference](hpm-part/hpm-part-reference.md) |
......@@ -48,7 +48,7 @@ In addition, OpenHarmony provides a wide array of system components that can be
| About OpenHarmony| Getting familiar with OpenHarmony| - [About OpenHarmony](https://gitee.com/openharmony)<br>- [Glossary](../glossary.md)|
| Development resources| Preparing for your development| - [Obtaining Source Code](get-code/sourcecode-acquire.md)<br>- [Obtaining Tools](get-code/gettools-acquire.md)|
| Getting started| Getting started with setup, build, burning, debugging, and running of OpenHarmony| - [Standard System Overview](quick-start/quickstart-ide-standard-overview.md) |
| Basic capabilities| Using basic capabilities of OpenHarmony| - [Kernel Development](kernel/kernel-standard.md)<br>- [HDF](driver/driver-hdf-overview.md)<br>- [Subsystems](subsystems/subsys-build-standard-large.md)<br>- [Security Guidelines](security/security-guidelines-overall.md)<br>- [Privacy Protection](security/security-privacy-protection.md)|
| Basic capabilities| Using basic capabilities of OpenHarmony| - [Kernel Development](kernel/kernel-standard-overview.md)<br>- [HDF](driver/driver-hdf-overview.md)<br>- [Subsystems](subsystems/subsys-build-all.md)<br>- [Security Guidelines](security/security-guidelines-overall.md)<br>- [Privacy Protection](security/security-privacy-protection.md) |
| Advanced development| Developing smart devices based on system capabilities| - [Development Guidelines on Clock Apps](guide/device-clock-guide.md)<br>- [Development Example for Platform Drivers](guide/device-driver-demo.md)<br>- [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) |
| Porting and adaptation| - Porting and adapting OpenHarmony to an SoC<br>- Rapidly porting the OpenHarmony Linux kernel| - [Standard System Porting Guide](porting/standard-system-porting-guide.md)<br>- [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md) |
| Contributing components| Contributing components to OpenHarmony| - [HPM Part Overview](hpm-part/hpm-part-about.md)<br>- [HPM Part Development](hpm-part/hpm-part-development.md)<br>- [HPM Part Reference](hpm-part/hpm-part-reference.md) |
......
......@@ -25,11 +25,11 @@ The identity authentication consists of User_auth and basic authentication servi
- Executor role
- Executor: independently completes the entire process of credential registration and identity authentication. The executor can collect, process, store, and compare data to complete the authentication.
- Executor: independently completes the entire process of credential registration and identity authentication. The executor can collect, process, store, and compare data to complete the authentication.
- Collector: only collects data during user authentication. It needs to work with the authenticator to complete user authentication.
- Collector: only collects data during user authentication. It needs to work with the authenticator to complete user authentication.
- Authenticator: only processes data, obtains the stored credential template, and compares it with the authentication information generated.
- Authenticator: only processes data, obtains the stored credential template, and compares it with the authentication information generated.
- Executor type
......@@ -56,7 +56,7 @@ The identity authentication consists of User_auth and basic authentication servi
The Pin_auth driver provides basic PIN authentication capabilities for the upper-layer User_auth and Pin_auth service to ensure successful PIN authentication. You can develop drivers to call Hardware Device Interface (HDI) APIs based on the HDF and the chip you use.
**Figure 2** Pin_auth service and pin_auth driver APIs
**Figure 2** Pin_auth service and Pin_auth driver APIs
![image](figures/pin_auth_service_and_driver_interaction.png "interaction between the pin_auth service and driver")
......@@ -93,24 +93,32 @@ The Pin_auth driver provides basic PIN authentication capabilities for the User_
### How to Develop
The following uses the RK3568 platform as an example to demonstrate how to develop the Pin_auth driver. <br/>The directory structure is as follows:
The following uses the RK3568 platform as an example to demonstrate how to develop the Pin_auth driver.
```
The directory structure is as follows:
```text
// drivers/peripheral/pin_auth
├── BUILD.gn # Build script
├── bundle.json # Module description file
├── test # Test cases
└── hdi_service # Pin_auth driver implementation
├── BUILD.gn # Build script
├── inc # Header files
└── src
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
├── pin_auth_interface_driver.cpp # Pin_auth driver entry
└── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list
├── adaptor # Implementation of related algorithms
├── common # Implementation of common interfaces
├── database # Database implementation
├── main # Entry for implementing PIN-related functions
└── service # Entry for implementing the Pin_auth driver
├── inc # Header files
└── src
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
├── pin_auth_interface_driver.cpp # Pin_auth driver entry
└── pin_auth_interface_service.cpp # Implementation of the APIs for obtaining the executor list
```
The development procedure is as follows:
1. Develop the Pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/pin_auth_interface_driver.cpp).
1. Develop the Pin_auth driver based on the HDF. The **Bind()**, **Init()**, **Release()**, and **Dispatch()** functions are used. For details about the code, see [pin_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_driver.cpp).
```c++
// Create the PinAuthInterfaceService object by using the custom HdfPinAuthInterfaceHost object, which consists of the IoService object and HDI service.
......@@ -212,7 +220,7 @@ The development procedure is as follows:
1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/pin_auth_interface_service.cpp).
1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_service.cpp).
```c++
// Executor implementation class
......@@ -285,7 +293,7 @@ The development procedure is as follows:
1. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/src/executor_impl.cpp).
1. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/executor_impl.cpp).
```c++
// Obtain executor information (example only).
......@@ -526,7 +534,8 @@ The development procedure is as follows:
### Verification
Verify whether PIN authentication can be successfully performed on the RK3568 platform as follows:
1. Set a PIN.<br/>
1. Set a PIN.
Touch **Settings** > **Biometrics & passwords** > **Password**, and enter your password.
2. Verify PIN authentication.
......
......@@ -430,6 +430,8 @@ Initialize the controller hardware, call core-layer APIs to add or delete device
2. Build source code and burn images to the development board.
For details, see the related sections in [Getting Started for Standard System](../quick-start/quickstart-standard.md).
- For details about the operations using the installation package, see [Building](../quick-start/quickstart-ide-standard-running-hi3516-build.md) and [Burning](../quick-start/quickstart-ide-standard-running-hi3516-burning.md).
- For details about the operations in IDE mode, see [Building](../quick-start/quickstart-standard-running-hi3516-build.md) and [Burning](../quick-start/quickstart-standard-running-hi3516-burning.md).
......@@ -315,7 +315,7 @@ The input driver model consists of three parts of drivers. To develop a brand-ne
**touch\_gt911.o** is the content added in this example.
2. Build source code and burn images. For details, see the related sections in [Getting Started for Standard System](../quick-start/quickstart-standard.md).
2. Build source code and burn images. For details, see the related sections in [Standard System Overview](../quick-start/quickstart-standard-overview.md).
## Debugging and Verification<a name="section62577313482"></a>
......
......@@ -32,8 +32,9 @@ During system startup, **OsUserInitProcess** is called to start the **init**
- Starts key system programs or services, such as shell.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>In OpenHarmony, the **init** process reads the **/etc/init.cfg** file and runs specified commands or starts specified processes based on configurations. For details, see [init Module](../subsystems/subsys-boot-init.md).
>![](../public_sys-resources/icon-note.gif) **NOTE**
>
>In OpenHarmony, the **init** process reads the **/etc/init.cfg** file and runs specified commands or starts specified processes based on configurations. For details, see [init Module](../subsystems/subsys-boot-init-cfg.md).
- Monitors the process for reclaiming the orphan process and clears the zombie processes in child processes.
......
......@@ -92,7 +92,7 @@ For devices with 128 KB to 128 MB of memory, the OpenHarmony lite kernel is reco
### Mechanism<a name="section1378993720111"></a>
Huawei Universal Keystore Service \(HUKS\) provides key and certificate management. For OpenHarmony, it mainly provides key management for HiChain \(the device identity authentication platform\). The following figure shows the functions of HUKS
OpenHarmony Universal Keystore Service \(HUKS\) provides key and certificate management. For OpenHarmony, it mainly provides key management for HiChain \(the device identity authentication platform\). The following figure shows the functions of HUKS
**Figure 3** HUKS functions<a name="fig10710452133411"></a>
![](figure/huks-functions.png "huks-functions")
......
......@@ -534,7 +534,7 @@ When uninstalling an application, you can specify whether to retain application
```
sem_init(&g_sem, 0, 0);
const uint32_t WAIT_TIMEOUT = 30;
std::string BUNDLE_NAME = "com.huawei.demo"; // Bundle name of the application to be uninstalled
std::string BUNDLE_NAME = "com.example.demo"; // Bundle name of the application to be uninstalled
Uninstall(BUNDLE_NAME.c_str(), &installParam, UninstallCallback);
struct timespec ts = {};
clock_gettime(CLOCK_REALTIME, &ts);
......@@ -557,7 +557,7 @@ You can use the **GetBundleInfo** function provided by **BundleManager** to
2. Call **GetBundleInfo** to obtain bundle information about a specified application. The **bundleName** parameter indicates the pointer to the application bundle name, and the **flags** parameter specifies whether the obtained **BundleInfo** object can contain **AbilityInfo**.
```
std::string BUNDLE_NAME = "com.huawei.demo";
std::string BUNDLE_NAME = "com.example.demo";
uint8_t ret = GetBundleInfo(BUNDLE_NAME.c_str(), 1, &bundleInfo); // When flags is set to 1, the obtained BundleInfo object contains AbilityInfo.
```
......
# FAQs<a name="EN-US_TOPIC_0000001063231870"></a>
# FAQs
## System startup interrupted due to "parse failed!" error<a name="section2041345718513"></a>
## System startup interrupted due to "parse failed!" error
**Problem**
......@@ -17,7 +17,7 @@ During the modification of the **init.cfg** file, required commas \(,\) or par
Check the **init.cfg** file and ensure that its format meets the JSON specifications.
## System automatically restarted again and again<a name="section57381816168"></a>
## System automatically restarted again and again
**Problem**
......@@ -25,7 +25,7 @@ After the image burning is complete, the system keeps restarting.
**Cause**
Each service started by the init process has the **importance** attribute, as described in Table 3 in [init Module](subsys-boot-init.md).
Each service started by the init process has the **importance** attribute, as described in Table 3 in [Job Management](../subsystems/subsys-boot-init-jobs.md).
- If the attribute value is **0**, the init process does not need to restart the development board when the current service process exits.
- If the attribute value is **1**, the init process needs to restart the development board when the current service process exits.
......@@ -37,7 +37,7 @@ During the startup of a service whose **importance** is **1**, if the service
1. View logs to identify the service that encounters a process crash or exits due to an error, rectify the issue, and then burn the image again.
2. Alternatively, change the value of **importance** to **0** for the service that exits due to a process crash or an error, and then burn the image again. In this way, the development board will not be restarted even if the service exits.
## Failed to call the **SetParameter** or **GetParameter** API with correct parameter values<a name="section129991227141512"></a>
## Failed to call the **SetParameter** or **GetParameter** API with correct parameter values
**Problem**
......
......@@ -23,7 +23,7 @@ When the system is powered on, the kernel loads and starts services and applicat
The Startup subsystem consists of the following modules:
- init module<br>
This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in [Table 2](../subsystems/subsys-boot-init.md) and starts the key system service processes in sequence with corresponding permissions granted.
This module corresponds to the init process, which is the first user-mode process started after the kernel is initialized. After the init process starts, it reads and parses the **init.cfg** file. Based on the parsing result, the init module executes the commands listed in Table 2 in [Job Management](../subsystems/subsys-boot-init-jobs.md) and starts the key system service processes in sequence with corresponding permissions granted.
- ueventd module<br>
This module listens for **netlink** events about hot swap of kernel device drivers and dynamically manages the **dev** node of the corresponding device based on the event type.
......
......@@ -20,6 +20,10 @@ The OpenHarmony security subsystem provides security capabilities that make your
The Device Security Level Management (DSLM) module is introduced to manage the security levels of OpenHarmony devices. When different types of user data are hopped or processed in OpenHarmony distributed services, the DSLM APIs can be called to obtain the security levels of related devices for subsequent processing.
- HUKS
The OpenHarmony Universal Keystore (HUKS) provides system-level key management capabilities, ensuring secure management and use of keys throughout their entire lifecycle (generation, storage, use, and destruction). Applications can call the APIs provided by the HUKS module to perform operations on keys. In addition, the keys in plaintext must be used in a trusted execution environment (TEE).
## Basic Concepts
......
......@@ -4,7 +4,6 @@ OpenHarmony provides a comprehensive auto-test framework for designing test case
This document describes how to use the OpenHarmony test framework.
## Setting Up the Environment
The test framework depends on the Python running environment. Before using the test framework, set up the environment as follows:
- [Setting Up the Environment](subsys-testguide-envbuild.md)
- [Obtaining Source Code](../get-code/sourcecode-acquire.md)
......@@ -419,21 +418,22 @@ The following provides templates for different languages for your reference.
1. Add comment information for the file header.
```
```
# Copyright (c) 2021 XXXX Device Co., Ltd.
```
2. Import the build template.
```
```
import("//build/test.gni")
```
3. Specify the file output path.
```
```
module_output_path = "subsystem_examples/calculator"
```
> **NOTE**<br>
> The output path is ***Part name*/*Module name***.
......@@ -470,15 +470,15 @@ The following provides templates for different languages for your reference.
}
```
> **NOTE**<br>
> Set the test type based on actual requirements. The following test types are available:
> - **ohos_unittest**: unit test
> - **ohos_moduletest**: module test
> - **ohos_systemtest**: system test
> - **ohos_performancetest**: performance test
> - **ohos_securitytest**: security test
> - **ohos_reliabilitytest**: reliability test
> - **ohos_distributedtest**: distributed test
> **NOTE**<br>
> Set the test type based on actual requirements. The following test types are available:<br>
> - **ohos_unittest**: unit test<br>
> - **ohos_moduletest**: module test<br>
> - **ohos_systemtest**: system test<br>
> - **ohos_performancetest**: performance test<br>
> - **ohos_securitytest**: security test<br>
> - **ohos_reliabilitytest**: reliability test<br>
> - **ohos_distributedtest**: distributed test<br>
7. Group the test case files by test type.
......@@ -490,7 +490,7 @@ The following provides templates for different languages for your reference.
```
> **NOTE**<br>
> Grouping test cases by test type allows you to execute a specific type of test cases when required.
- **Test case build file example (JavaScript)**
```
......@@ -530,6 +530,7 @@ The following provides templates for different languages for your reference.
```
module_output_path = "subsystem_examples/app_info"
```
> **NOTE**<br>
> The output path is ***Part name*/*Module name***.
......@@ -539,9 +540,10 @@ The following provides templates for different languages for your reference.
ohos_js_unittest("GetAppInfoJsTest") {
}
```
> **NOTE**
>- Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++.
>- The file generated for the JavaScript test suite must be in .hap format and named after the test suite name defined here. The test suite name must end with **JsTest**.
> **NOTE**<br>
> - Use the **ohos\_js\_unittest** template to define the JavaScript test suite. Pay attention to the difference between JavaScript and C++.
> - The file generated for the JavaScript test suite must be in .hap format and named after the test suite name defined here. The test suite name must end with **JsTest**.
5. Configure the **config.json** file and signature file, which are mandatory.
......@@ -623,6 +625,7 @@ The following provides templates for different languages for your reference.
deps = [ ":GetAppInfoJsTest" ]
}
```
> **NOTE**<br>
> Grouping test cases by test type allows you to execute a specific type of test cases when required.
......@@ -673,7 +676,7 @@ Perform the following steps:
resource_config_file = "//system/subsystem/partA/test/resource/calculator/ohos_test.xml"
}
```
>**NOTE**
>**NOTE**<br>
>- **target_name** indicates the test suite name defined in the **BUILD.gn** file in the **test** directory.**preparer** indicates the action to perform before the test suite is executed.
>- **src="res"** indicates that the test resources are in the **resource** directory under the **test** directory. **src="out"** indicates that the test resources are in the **out/release/$(*part*)** directory.
......@@ -748,7 +751,7 @@ After the build is complete, the test cases are automatically saved in **out/his
2. Copy **developertest** and **xdevice** from the Linux environment to the **Test** directory on Windows, and copy the test cases to the **testcase** directory.
> **NOTE**<br>
> Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution.
> Port the test framework and test cases from the Linux environment to the Windows environment for subsequent execution.
3. Modify the **user_config.xml** file.
```
......@@ -761,9 +764,10 @@ After the build is complete, the test cases are automatically saved in **out/his
<dir>D:\Test\testcase\tests</dir>
</test_cases>
```
> **NOTE**<br>
> `<testcase>` indicates whether to build test cases. `<dir>` indicates the path for searching for test cases.
#### Executing Test Cases
1. Start the test framework.
```
......@@ -796,16 +800,18 @@ To enable test cases to be executed on a remote Linux server or a Linux VM, map
hdc_std kill
hdc_std -m -s 0.0.0.0:8710
```
> **NOTE**<br>
> The IP address and port number are default values.
2. On the HDC client, run the following command:
```
hdc_std -s xx.xx.xx.xx:8710 list targets
```
> **NOTE**<br>
> Enter the IP address of the device to test.
#### Executing Test Cases
1. Start the test framework.
```
......
# OpenHarmony Device Development Documentation
- [Device Development Guide](device-dev-guide.md)
- Getting Started
- Getting Started with Mini and Small Systems (IDE Mode, Recommended)
- [Mini and Small System Overview](quick-start/quickstart-ide-lite-overview.md)
- Environment Preparation
- [Setting Up the Windows+Ubuntu Hybrid Build Environment](quick-start/quickstart-ide-lite-env-setup-win-ubuntu.md)
- [Obtaining Source Code](quick-start/quickstart-ide-lite-sourcecode-acquire.md)
- [Creating a Source Code Project](quick-start/quickstart-ide-lite-create-project.md)
- Running a Hello World Program
- Hi3861 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md)
- [Building](quick-start/quickstart-ide-lite-steps-hi3861-building.md)
- [Burning](quick-start/quickstart-ide-lite-steps-hi3861-burn.md)
- [Networking](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md)
- [Debugging and Verification](quick-start/quickstart-ide-lite-steps-hi3861-debug.md)
- [Running](quick-start/quickstart-ide-lite-steps-hi3861-running.md)
- Hi3516 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md)
- [Building](quick-start/quickstart-ide-lite-steps-hi3516-building.md)
- [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md)
- [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md)
- Appendix
- [Introduction to the Hi3861 Development Board](quick-start/quickstart-ide-lite-introduction-hi3861.md)
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-lite-introduction-hi3516.md)
- [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md)
- Getting Started with Mini and Small Systems (Installation Package Mode)
- [Mini and Small System Overview](quick-start/quickstart-lite-overview.md)
- [Environment Preparation](quick-start/quickstart-lite-env-setup.md)
- Running a Hello World Program
- Hi3861 Development Board
- [Setting Up the Hi3861 Development Board Environment](quick-start/quickstart-lite-steps-hi3861-setting.md)
- [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3861-helloworld.md)
- [Building](quick-start/quickstart-lite-steps-hi3861-building.md)
- [Burning](quick-start/quickstart-lite-steps-hi3861-burn.md)
- [Networking](quick-start/quickstart-lite-steps-hi3861-netconfig.md)
- [Debugging and Verification](quick-start/quickstart-lite-steps-hi3861-debug.md)
- [Running](quick-start/quickstart-lite-steps-hi3861-running.md)
- Hi3516 Development Board
- [Setting Up the Hi3516 Development Board Environment](quick-start/quickstart-lite-steps-hi3516-setting.md)
- [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3516-helloworld.md)
- [Building](quick-start/quickstart-lite-steps-hi3516-building.md)
- [Burning](quick-start/quickstart-lite-steps-hi3516-burn.md)
- [Running](quick-start/quickstart-lite-steps-hi3516-running.md)
- FAQs
- [Fixing hb Installation Issues](quick-start/quickstart-lite-faq-hb.md)
- [Fixing Compilation Issues](quick-start/quickstart-lite-faq-compose.md)
- [Fixing Burning Issues](quick-start/quickstart-lite-faq-burning.md)
- Appendix
- Introduction to Development Boards
- [Introduction to the Hi3861 Development Board](quick-start/quickstart-lite-introduction-hi3861.md)
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-lite-introduction-hi3516.md)
- [Reference](quick-start/quickstart-lite-reference.md)
- [Burning Code by Using HiTool](quick-start/quickstart-lite-hitool.md)
- [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md)
- Getting Started with Standard System (IDE Mode, Recommended)
- [Standard System Overview](quick-start/quickstart-ide-standard-overview.md)
- Environment Preparation
- [Setting Up the Windows+Ubuntu Hybrid Build Environment](quick-start/quickstart-ide-standard-env-setup-win-ubuntu.md)
- [Obtaining Source Code](quick-start/quickstart-ide-standard-sourcecode-acquire.md)
- [Creating a Source Code Project](quick-start/quickstart-ide-standard-create-project.md)
- Running a Hello World Program
- Hi3516 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-standard-running-hi3516-create.md)
- [Building](quick-start/quickstart-ide-standard-running-hi3516-build.md)
- [Burning](quick-start/quickstart-ide-standard-running-hi3516-burning.md)
- [Running](quick-start/quickstart-ide-standard-running-hi3516-running.md)
- RK3568 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-standard-running-rk3568-create.md)
- [Building](quick-start/quickstart-ide-standard-running-rk3568-build.md)
- [Burning](quick-start/quickstart-ide-standard-running-rk3568-burning.md)
- [Running](quick-start/quickstart-ide-standard-running-rk3568-running.md)
- Appendix
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-ide-standard-board-introduction-hi3516.md)
- [Introduction to the RK3568 Development Board](quick-start/quickstart-ide-standard-board-introduction-rk3568.md)
- [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md)
- Getting Started with Standard System (Installation Package Mode)
- [Standard System Overview](quick-start/quickstart-standard-overview.md)
- [Setting Up Environments for Standard System](quick-start/quickstart-standard-env-setup.md)
- Running a Hello World Program
- Hi3516 Development Board
- [Writing a Hello World Program](quick-start/quickstart-std-3516-create.md)
- [Building](quick-start/quickstart-standard-running-hi3516-build.md)
- [Burning](quick-start/quickstart-standard-running-hi3516-burning.md)
- [Running](quick-start/quickstart-standard-running-hi3516-running.md)
- RK3568 Development Board
- [Writing a Hello World Program](quick-start/quickstart-standard-running-rk3568-create.md)
- [Building](quick-start/quickstart-standard-running-rk3568-build.md)
- [Burning](quick-start/quickstart-standard-running-rk3568-burning.md)
- [Running](quick-start/quickstart-standard-running-rk3568-running.md)
- FAQs
- [Fixing hb Installation Issues](quick-start/quickstart-standard-faq-hb.md)
- [Fixing Compilation Issues](quick-start/quickstart-standard-faq-compose.md)
- [Fixing Burning Issues](quick-start/quickstart-standard-faq-burning.md)
- Appendix
- Introduction to Development Boards
- [Introduction to the Hi3516 Development Board](quick-start/quickstart-standard-board-introduction-hi3516.md)
- [Introduction to the RK3568 Development Board](quick-start/quickstart-standard-board-introduction-rk3568.md)
- [Reference](quick-start/quickstart-standard-reference.md)
- [Burning Code by Using HiTool](quick-start/quickstart-standard-hitool.md)
- [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md)
- [Overall Description of Compilation Form Factors](quick-start/quickstart-build.md)
- [Obtaining Source Code](get-code/sourcecode-acquire.md)
- Compatibility and Security
- [Privacy Protection](security/security-privacy-protection.md)
- [Security Guidelines](security/security-guidelines-overall.md)
- Porting
- Mini System SoC Porting Guide
- Porting Preparations
- [Before You Start](porting/porting-chip-prepare-knows.md)
- [Building Adaptation Process](porting/porting-chip-prepare-process.md)
- Kernel Porting
- [Porting Overview](porting/porting-chip-kernel-overview.md)
- [Basic Kernel Adaptation](porting/porting-chip-kernel-adjustment.md)
- [Kernel Porting Verification](porting/porting-chip-kernel-verify.md)
- Board-Level OS Porting
- [Porting Overview](porting/porting-chip-board-overview.md)
- [Board-Level Driver Adaptation](porting/porting-chip-board-driver.md)
- [Implementation of APIs at the HAL](porting/porting-chip-board-hal.md)
- [System Modules](porting/porting-chip-board-component.md)
- [lwIP Module Adaptation](porting/porting-chip-board-lwip.md)
- [Third-party Module Adaptation](porting/porting-chip-board-bundle.md)
- [XTS](porting/porting-chip-board-xts.md)
- [FAQs](porting/porting-chip-faqs.md)
- Small System SoC Porting Guide
- Porting Preparations
- [Before You Start](porting/porting-smallchip-prepare-needs.md)
- [Compilation and Building](porting/porting-smallchip-prepare-building.md)
- Kernel Porting
- [LiteOS Cortex-A](porting/porting-smallchip-kernel-a.md)
- [Linux Kernel](porting/porting-smallchip-kernel-linux.md)
- Driver Porting
- [Porting Overview](porting/porting-smallchip-driver-overview.md)
- [Platform Driver Porting](porting/porting-smallchip-driver-plat.md)
- [Device Driver Porting](porting/porting-smallchip-driver-oom.md)
- Standard System SoC Porting Guide
- [Standard System Porting Guide](porting/standard-system-porting-guide.md)
- [A Method for Rapidly Porting the OpenHarmony Linux Kernel](porting/porting-linux-kernel.md)
- Third-Party Library Porting Guide for Mini and Small Systems
- [Overview](porting/porting-thirdparty-overview.md)
- [Porting a Library Built Using CMake](porting/porting-thirdparty-cmake.md)
- [Porting a Library Built Using Makefile](porting/porting-thirdparty-makefile.md)
- Mini System SoC Porting Cases
- [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting/porting-bes2600w-on-minisystem-display-demo.md)
- [Combo Solution – ASR Chip Porting Case](porting/porting-asr582x-combo-demo.md)
- Subsystem Development
- Kernel
......@@ -164,10 +252,7 @@
- Basic Kernel
- [Interrupt Management](kernel/kernel-mini-basic-interrupt.md)
- [Task Management](kernel/kernel-mini-basic-task.md)
- Memory Management
- [Basic Concepts](kernel/kernel-mini-basic-memory-basic.md)
- [Static Memory](kernel/kernel-mini-basic-memory-static.md)
- [Dynamic Memory](kernel/kernel-mini-basic-memory-dynamic.md)
- [Memory Management](kernel/kernel-mini-basic-memory.md)
- Kernel Communication Mechanisms
- [Event](kernel/kernel-mini-basic-ipc-event.md)
- [Mutex](kernel/kernel-mini-basic-ipc-mutex.md)
......@@ -179,23 +264,16 @@
- [C++ Support](kernel/kernel-mini-extend-support.md)
- [CPUP](kernel/kernel-mini-extend-cpup.md)
- [Dynamic Loading](kernel/kernel-mini-extend-dynamic-loading.md)
- File System
- [FAT](kernel/kernel-mini-extend-file-fat.md)
- [LittleFS](kernel/kernel-mini-extend-file-lit.md)
- [File System](kernel/kernel-mini-extend-file.md)
- Kernel Debugging
- Memory Debugging
- [Memory Information Statistics](kernel/kernel-mini-memory-debug-mes.md)
- [Memory Leak Check](kernel/kernel-mini-memory-debug-det.md)
- [Memory Corruption Check](kernel/kernel-mini-memory-debug-cet.md)
- [Memory Debugging](kernel/kernel-mini-memory-debug.md)
- [Exception Debugging](kernel/kernel-mini-memory-exception.md)
- [Trace](kernel/kernel-mini-memory-trace.md)
- [LMS](kernel/kernel-mini-memory-lms.md)
- Appendix
- [Kernel Coding Specification](kernel/kernel-mini-appx-code.md)
- [Doubly Linked List](kernel/kernel-mini-appx-data-list.md)
- Standard Libraries
- [CMSIS Support](kernel/kernel-mini-appx-lib-cmsis.md)
- [POSIX Support](kernel/kernel-mini-appx-lib-posix.md)
- [Standard Libraries](kernel/kernel-mini-appx-lib.md)
- Kernel for Small Systems
- [Kernel Overview](kernel/kernel-small-overview.md)
- Kernel Startup
......@@ -230,12 +308,7 @@
- [LiteIPC](kernel/kernel-small-bundles-ipc.md)
- File Systems
- [Virtual File System](kernel/kernel-small-bundles-fs-virtual.md)
- Supported File Systems
- [FAT](kernel/kernel-small-bundles-fs-support-fat.md)
- [JFFS2](kernel/kernel-small-bundles-fs-support-jffs2.md)
- [NFS](kernel/kernel-small-bundles-fs-support-nfs.md)
- [Ramfs](kernel/kernel-small-bundles-fs-support-ramfs.md)
- [procfs](kernel/kernel-small-bundles-fs-support-procfs.md)
- [Supported File Systems](kernel/kernel-small-bundles-fs-support.md)
- [File System Adaptation](kernel/kernel-small-bundles-fs-new.md)
- Debugging and Tools
- Shell
......@@ -313,15 +386,7 @@
- [Memory Information Statistics](kernel/kernel-small-debug-memory-info.md)
- [Memory Leak Check](kernel/kernel-small-debug-memory-leak.md)
- [Memory Corruption Check](kernel/kernel-small-debug-memory-corrupt.md)
- User-Mode Memory Debugging
- [Basic Concepts](kernel/kernel-small-debug-user-concept.md)
- [Working Principles](kernel/kernel-small-debug-user-function.md)
- Usage
- [API Description](kernel/kernel-small-debug-user-guide-api.md)
- How to Use
- [Calling APIs](kernel/kernel-small-debug-user-guide-use-api.md)
- [Using the CLI](kernel/kernel-small-debug-user-guide-use-cli.md)
- [Typical Memory Problems](kernel/kernel-small-debug-user-faqs.md)
- [User-Mode Memory Debugging](kernel/kernel-small-debug-user.md)
- Other Kernel Debugging Methods
- [Dying Gasp](kernel/kernel-small-debug-trace-other-lastwords.md)
- [Common Fault Locating Methods](kernel/kernel-small-debug-trace-other-faqs.md)
......@@ -400,6 +465,21 @@
- [Compilation and Building Guide](subsystems/subsys-build-all.md)
- [Build System Coding Specifications and Best Practices](subsystems/subsys-build-gn-coding-style-and-best-practice.md)
- [Building the Kconfig Visual Configuration](subsystems/subsys-build-gn-kconfig-visual-config-guide.md)
- References
- [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules)
- [Product Configuration Rules](subsystems/subsys-build-product.md#configuration-rules)
- [Subsystem Configuration Rules](subsystems/subsys-build-subsystem.md#configuration-rules)
- [Component Configuration Rules](subsystems/subsys-build-component.md#configuration-rules)
- [Module Configuration Rules](subsystems/subsys-build-module.md#configuration-rules)
- [Chipset Solution Configuration Rules](subsystems/subsys-build-chip_solution.md#configuration-rules)
- [Feature Configuration Rules](subsystems/subsys-build-feature.md#configuration-rules)
- [System Capabilities Configuration Rules](subsystems/subsys-build-syscap.md#configuring-system-capabilities-for-a-component)
- [deps and external_deps](subsystems/subsys-build-reference.md#deps-and-external_deps)
- [Information Collected by the Open Source Software Notice](subsystems/subsys-build-reference.md#information-collected-by-the-open-source-software-notice)
- [Parameters for Accelerating Local Build](subsystems/subsys-build-reference.md#parameters-for-accelerating-local-build)
- [Viewing Ninja Build Information](subsystems/subsys-build-reference.md#viewing-ninja-build-information)
- [HAP Build Guide](subsystems/subsys-build-gn-hap-compilation-guide.md)
- [FAQs](subsystems/subsys-build-FAQ.md)
- [Distributed Remote Startup](subsystems/subsys-remote-start.md)
- Graphics
- [Graphics Overview](subsystems/subsys-graphics-overview.md)
......@@ -464,9 +544,9 @@
- [Security Overview](subsystems/subsys-security-overview.md)
- [Development on Application Signature Verification](subsystems/subsys-security-sigverify.md)
- [Development on Application Permission Management](subsystems/subsys-security-rightmanagement.md)
- [Development on IPC Authentication](subsystems/subsys-security-communicationverify.md)
- [Development on Device Security Level Management](subsystems/subsys-security-devicesecuritylevel.md)
- Startup
- [Startup](subsystems/subsys-boot-overview.md)
- init Module
......@@ -500,9 +580,13 @@
- Featured Topics
- HPM Part
- [HPM Part Overview](hpm-part/hpm-part-about.md)
- [HPM Part Development](hpm-part/hpm-part-development.md)
- [HPM Part Reference](hpm-part/hpm-part-reference.md)
- Device Development Examples
- Mini- and Small-System Devices
- WLAN-connected Products
- [LED Peripheral Control](guide/device-wlan-led-control.md)
......@@ -535,8 +619,9 @@
- [Development Guidelines on Clock Apps](guide/device-clock-guide.md)
- [Development Example for Platform Drivers](guide/device-driver-demo.md)
- [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md)
- Debugging
- Debugging
- [Test Case Development](subsystems/subsys-testguide-test.md)
- Debugging Tools
- [bytrace](subsystems/subsys-toolchain-bytrace-guide.md)
......@@ -558,3 +643,11 @@
- [Porting](faqs/faqs-porting.md)
- [Startup](faqs/faqs-startup.md)
- [System Applications](faqs/faqs-system-applications.md)
# utils<a name="EN-US_TOPIC_0000001092539399"></a>
# commonlibrary<a name="EN-US_TOPIC_0000001092539399"></a>
## Introduction<a name="section11660541593"></a>
The **utils** repository provides common enhanced APIs for development in C and C++.
The **commonlibrary** subsystem provides common enhanced APIs for development in C, C++ and JS.
**C++**
**c_utils**
- Enhanced APIs for operations related to files, paths, and strings
- APIs related to the read-write lock, semaphore, timer, thread, and thread pool
......@@ -13,7 +13,14 @@ The **utils** repository provides common enhanced APIs for development in C and
- Error codes for each subsystem
- Safe functions in C
**C**
**ets_utils**
- JSAPIs for operation of URI, URL and xml
- JSAPIs for character encoder and decoder
- JSAPIs for operation of process
- Multithreading ability in JS
**utils_lite**
- Hardware Abstraction Layer (HAL) APIs for performing operations on standard files
- APIs for internal functions, such as the timer
......@@ -21,17 +28,18 @@ The **utils** repository provides common enhanced APIs for development in C and
## Directory Structure<a name="section17271017133915"></a>
```
/utils
├── native # Utility class implementation at the native layer
└── system # System-related predefined values and security policy configuration
/commonlibrary
├── c_utils # Enhanced basic C/C++ library for developers
├── ets_utils # Enhanced basic JS library for developers
└── utils_lite # Basic tools for liteOS, including C and JS.
```
## Repositories Involved<a name="section1249817110914"></a>
**utils subsystem**
**commonlibrary subsystem**
[utils](https://gitee.com/openharmony/utils)
[commonlibrary\_c\_utils](https://gitee.com/openharmony/commonlibrary_c_utils)
[utils\_native](https://gitee.com/openharmony/utils_native)
[commonlibrary\_ets\_utils](https://gitee.com/openharmony/commonlibrary_ets_utils)
[utils\_native\_lite](https://gitee.com/openharmony/utils_native_lite)
[commonlibrary\_utils\_lite](https://gitee.com/openharmony/commonlibrary_utils_lite)
......@@ -40,7 +40,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
1. 获取设备列表。
```js
// 导入usb接口api包。
// 导入USB接口api包。
import usb from '@ohos.usb';
// 获取设备列表。
var deviceList = usb.getDevices();
......
......@@ -19,4 +19,5 @@
- [图片开发指导](image.md)
- 相机
- [相机开发指导](camera.md)
\ No newline at end of file
- [相机开发指导](camera.md)
- [分布式相机开发指导](remote-camera.md)
\ No newline at end of file
......@@ -86,7 +86,7 @@ NativeWindow是`OpenHarmony`**本地平台化窗口**,包括从`Surface`构建
SkImageInfo imageInfo = ...
bitmap.setInfo(imageInfo, bufferHandle->stride);
bitmap.setPixels(bufferHandle->virAddr);
//创建 Skia Canvas 并将内容写入naitve window
//创建 Skia Canvas 并将内容写入native window
...
//写入完成后,通过OH_NativeWindow_NativeWindowFlushBuffer 提交给消费者使用,例如:显示在屏幕上
......@@ -101,7 +101,13 @@ NativeWindow是`OpenHarmony`**本地平台化窗口**,包括从`Surface`构建
OH_NativeXComponent_Callback &callback_;
callback_->OnSurfaceCreated = OnSurfaceCreatedCB;
callback_->OnSurfaceChanged = OnSurfaceChangedCB;
callback_->OnSurfaceDestoryed = OnSurfaceDestoryedCB;
callback_->OnSurfaceDestroyed = OnSurfaceDestroyedCB;
callback_->DispatchTouchEvent = DispatchTouchEventCB;
OH_NativeXComponent_RegisterCallback(nativeXComponent, callback_)
```
## 相关实例
针对NativeWindow的使用,有以下相关实例可供参考:
- [使用NativeWindow接口获取Buffer](https://gitee.com/openharmony/graphic_graphic_2d/blob/master/rosen/samples/hello_native_window/hello_native_window.cpp)
......@@ -13,7 +13,7 @@
![01](figures/01.png)
2. 进入配置工程界面,**Compile SDK** 选择“**8**”(**Complie SDK**选择“**9**”时注意同步选择**Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**eTS**”,其他参数保持默认设置即可。
2. 进入配置工程界面,**Compile SDK** 选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择**Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**eTS**”,其他参数保持默认设置即可。
![02](figures/02.png)
......
......@@ -11,7 +11,7 @@
![01](figures/01.png)
2. 进入配置工程界面,**Compile SDK**选择“**8**”(**Complie SDK**选择“**9**”时注意同步选择 **Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**JS**”,其他参数保持默认设置即可。
2. 进入配置工程界面,**Compile SDK**选择“**8**”(**Compile SDK**选择“**9**”时注意同步选择 **Model** 为“**FA**”,此处以选择“**8**”为例),**Language**选择“**JS**”,其他参数保持默认设置即可。
![04](figures/04.png)
......
......@@ -141,7 +141,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
## bundle.getApplicationInfoSync<sup>9+</sup>
getApplicationInfoSync(bundleName: string, bundleFlags: string, userId: number): ApplicationInfo;
getApplicationInfoSync(bundleName: string, bundleFlags: number, userId: number): ApplicationInfo;
以同步方法根据给定的包名获取ApplicationInfo,返回ApplicationInfo对象。
......
......@@ -282,6 +282,32 @@ promise.then(data => {
});
```
### getVersion
getVersion(): Promise&lt;number&gt;
获取当前权限管理的数据版本,使用Promise方式异步返回结果。
此接口为系统接口。
**系统能力:** SystemCapability.Security.AccessToken
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回的版本号。 |
**示例:**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let promise = AtManager.getVersion();
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
```
### on<sup>9+</sup>
on(type: 'permissionStateChange', tokenIDList: Array&lt;number&gt;, permissionNameList: Array&lt;string&gt;, callback: Callback&lt;PermissionStateChangeInfo&gt;): void;
......@@ -381,7 +407,7 @@ catch(err){
| 名称 | 默认值 | 描述 |
| ----------------------- | ------ | ----------------- |
| PERMISSION_REVOKED_OPER | 0 | 表示权限取消操作。 |
| PERMISSION_GRANTED | 1 | 表示权限授予操作。 |
| PERMISSION_GRANTED_OPER | 1 | 表示权限授予操作。 |
### PermissionStateChangeInfo<sup>9+</sup>
......
......@@ -816,7 +816,7 @@ getAssociatedDataSync(name: string, key: string): string;
| 类型 | 说明 |
| :-------------------- | :-------------------- |
| string | 用于获取同步接口的返回结果。 |
| string | 目标关联数据的取值。 |
**示例:**
......
......@@ -26,7 +26,7 @@ onReceiveEvent(event: CommonEventData): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | CommonEventData | 是 | 静态订阅者通用事件回调。 |
| event | [CommonEventData](js-apis-commonEvent.md#commoneventdata) | 是 | 静态订阅者通用事件回调。 |
**示例:**
......
......@@ -224,7 +224,7 @@ getProcessRunningInformation(): Promise\<Array\<ProcessRunningInformation>>;
| 类型 | 说明 |
| -------- | -------- |
| Promise\<Array\<ProcessRunningInformation>> | 获取有关运行进程的信息。 |
| Promise\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | 获取有关运行进程的信息。 |
**示例:**
......@@ -250,7 +250,7 @@ getProcessRunningInformation(callback: AsyncCallback\<Array\<ProcessRunningInfor
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback\<Array\<ProcessRunningInformation>> | 否 | 获取有关运行进程的信息。 |
| callback | AsyncCallback\<Array\<[ProcessRunningInformation](#processrunninginformation)>> | 否 | 获取有关运行进程的信息。 |
**示例:**
......@@ -863,3 +863,16 @@ onProcessDied(processData: ProcessData): void;
| [onAbilityStateChanged<sup>8+</sup>](#applicationstateobserveronabilitystatechanged8) | AsyncCallback\<void> | 是 | 否 | ability状态发生变化时执行的回调函数。 |
| [onProcessCreated<sup>8+</sup>](#applicationstateobserveronprocesscreated8) | AsyncCallback\<void> | 是 | 否 | 进程创建时执行的回调函数。 |
| [onProcessDied<sup>8+</sup>](#applicationstateobserveronprocessdied8) | AsyncCallback\<void> | 是 | 否 | 进程销毁时执行的回调函数。 |
## ProcessRunningInformation
进程的运行信息。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| pid<sup>9+</sup> | 只读 | number | 否 | 进程ID。 |
| uid<sup>9+</sup> | 只读 | number | 否 | 用户ID。 |
| processName<sup>9+</sup> | 只读 | string | 否 | 进程的名称。 |
| bundleNames<sup>9+</sup> | 只读 | Array\<string> | 否 | 进程中运行的bundleName数组。 |
\ No newline at end of file
......@@ -54,60 +54,6 @@ getAudioManager(): AudioManager
var audioManager = audio.getAudioManager();
```
## audio.getStreamManager<sup>9+</sup>
getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void
获取音频流管理器实例。使用callback方式异步返回结果。
**系统能力:** SystemCapability.Multimedia.Audio.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | 是 | 返回音频流管理器实例。 |
**示例:**
```js
audio.getStreamManager((err, data) => {
if (err) {
console.error(`getStreamManager : Error: ${err}`);
} else {
console.info('getStreamManager : Success : SUCCESS');
let audioStreamManager = data;
}
});
```
## audio.getStreamManager<sup>9+</sup>
getStreamManager(): Promise<AudioStreamManager\>
获取音频流管理器实例。使用Promise方式异步返回结果。
**系统能力:** SystemCapability.Multimedia.Audio.Core
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------- | ---------------- |
| Promise<[AudioStreamManager](#audiostreammanager9)> | 返回音频流管理器实例。 |
**示例:**
```js
var audioStreamManager;
audio.getStreamManager().then((data) => {
audioStreamManager = data;
console.info('getStreamManager: Success!');
}).catch((err) => {
console.error(`getStreamManager: ERROR : ${err}`);
});
```
## audio.createAudioRenderer<sup>8+</sup>
createAudioRenderer(options: AudioRendererOptions, callback: AsyncCallback\<AudioRenderer>): void
......@@ -667,6 +613,8 @@ audio.createAudioCapturer(audioCapturerOptions).then((data) => {
枚举,设备连接类型。
**系统接口:** 该接口为系统接口
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 默认值 | 描述 |
......@@ -1950,6 +1898,7 @@ setAudioScene\(scene: AudioScene, callback: AsyncCallback<void\>\): void
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) {
console.error(`Failed to set the audio scene mode.​ ${err}`);
......@@ -1984,6 +1933,7 @@ setAudioScene\(scene: AudioScene\): Promise<void\>
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => {
console.info('Promise returned to indicate a successful setting of the audio scene mode.');
}).catch ((err) => {
......@@ -2008,6 +1958,7 @@ getAudioScene\(callback: AsyncCallback<AudioScene\>\): void
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.getAudioScene((err, value) => {
if (err) {
console.error(`Failed to obtain the audio scene mode.​ ${err}`);
......@@ -2035,6 +1986,7 @@ getAudioScene\(\): Promise<AudioScene\>
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.getAudioScene().then((value) => {
console.info(`Promise returned to indicate that the audio scene mode is obtained ${value}.`);
}).catch ((err) => {
......@@ -2061,6 +2013,7 @@ getVolumeGroups(networkId: string, callback: AsyncCallback<VolumeGroupInfos\>\):
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID, (err, value) => {
if (err) {
console.error(`Failed to obtain the volume group infos list. ${err}`);
......@@ -2121,6 +2074,7 @@ getGroupManager(groupId: number, callback: AsyncCallback<AudioGroupManager\>\):
**示例:**
```js
var audioManager = audio.getAudioManager();
async function getGroupManager(){
let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID);
if (value.length > 0) {
......@@ -2150,7 +2104,7 @@ getGroupManager(groupId: number\): Promise<AudioGroupManager\>
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------------------- | ---- | -------------- -- |
| ---------- | ---------------------------------------- | ---- | ---------------- |
| networkId | string | 是 | 设备的网络id。 |
**返回值:**
......@@ -2162,6 +2116,7 @@ getGroupManager(groupId: number\): Promise<AudioGroupManager\>
**示例:**
```js
var audioManager = audio.getAudioManager();
async function getGroupManager(){
let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID);
if (value.length > 0) {
......@@ -2171,6 +2126,63 @@ async function getGroupManager(){
}
}
```
### getStreamManager<sup>9+</sup>
getStreamManager(callback: AsyncCallback\<AudioStreamManager>): void
获取音频流管理器实例。使用callback方式异步返回结果。
**系统能力:** SystemCapability.Multimedia.Audio.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback<[AudioStreamManager](#audiostreammanager9)> | 是 | 返回音频流管理器实例。 |
**示例:**
```js
var audioManager = audio.getAudioManager();
audioManager.getStreamManager((err, data) => {
if (err) {
console.error(`getStreamManager : Error: ${err}`);
} else {
console.info('getStreamManager : Success : SUCCESS');
let audioStreamManager = data;
}
});
```
### getStreamManager<sup>9+</sup>
getStreamManager(): Promise<AudioStreamManager\>
获取音频流管理器实例。使用Promise方式异步返回结果。
**系统能力:** SystemCapability.Multimedia.Audio.Core
**返回值:**
| 类型 | 说明 |
| ---------------------------------------------------- | ---------------- |
| Promise<[AudioStreamManager](#audiostreammanager9)> | 返回音频流管理器实例。 |
**示例:**
```js
var audioManager = audio.getAudioManager();
var audioStreamManager;
audioManager.getStreamManager().then((data) => {
audioStreamManager = data;
console.info('getStreamManager: Success!');
}).catch((err) => {
console.error(`getStreamManager: ERROR : ${err}`);
});
```
### requestIndependentInterrupt<sup>9+</sup>
requestIndependentInterrupt(focusType: FocusType, callback: AsyncCallback<boolean\>\): void
......@@ -2202,7 +2214,7 @@ async function requestIndependentInterrupt(){
```
### requestIndependentInterrupt<sup>9+</sup>
requestIndependentInterrupt(focusType: FocusType: Promise<boolean\>
requestIndependentInterrupt(focusType: FocusType): Promise<boolean\>
申请独立焦点,获取独立SessionID,使用promise方式异步返回结果。
......@@ -2264,7 +2276,7 @@ async function abandonIndependentInterrupt(){
```
### abandonIndependentInterrupt<sup>9+</sup>
abandonIndependentInterrupt(focusType: FocusType]: Promise<boolean\>
abandonIndependentInterrupt(focusType: FocusType): Promise<boolean\>
废除独立焦点,使用promise方式异步返回结果。
......@@ -2312,6 +2324,8 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2344,6 +2358,8 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise&lt;void&gt;
仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2373,6 +2389,8 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;): v
获取指定流的音量,使用callback方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2400,6 +2418,8 @@ getVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
获取指定流的音量,使用Promise方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2428,6 +2448,8 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
获取指定流的最小音量,使用callback方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2455,6 +2477,8 @@ getMinVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
获取指定流的最小音量,使用Promise方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2483,6 +2507,8 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback&lt;number&gt;)
获取指定流的最大音量,使用callback方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2510,6 +2536,8 @@ getMaxVolume(volumeType: AudioVolumeType): Promise&lt;number&gt;
获取指定流的最大音量,使用Promise方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2542,6 +2570,8 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback&lt;void
仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2574,6 +2604,8 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise&lt;void&gt;
仅设置铃声(即volumeType为AudioVolumeType.RINGTONE)在静音和非静音状态切换时需要该权限。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2603,6 +2635,8 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback&lt;boolean&gt;): voi
获取指定音量流是否被静音,使用callback方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2630,6 +2664,8 @@ isMute(volumeType: AudioVolumeType): Promise&lt;boolean&gt;
获取指定音量流是否被静音,使用Promise方式异步返回结果。
**系统接口:** 该接口为系统接口
**系统能力:** SystemCapability.Multimedia.Audio.Volume
**参数:**
......@@ -2654,7 +2690,7 @@ audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => {
## AudioStreamManager<sup>9+</sup>
管理音频流。在使用AudioStreamManager的API前,需要使用[getStreamManager](#audiogetstreammanager9)获取AudioStreamManager实例。
管理音频流。在使用AudioStreamManager的API前,需要使用[getStreamManager](#getstreammanager9)获取AudioStreamManager实例。
### getCurrentAudioRendererInfoArray<sup>9+</sup>
......@@ -3528,13 +3564,11 @@ promise.then(function (value) {
**系统接口:** 该接口为系统接口
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device
| 名称 | 类型 | 必填 | 说明 |
| -------------| ---------------------------------------- | ---- | -------------- |
| uid | number | 是 | 表示应用ID。<br> 系统能力:SystemCapability.Multimedia.Audio.Core|
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。<br> 系统能力:SystemCapability.Multimedia.Audio.Renderer|
| rendererId | number | 否 | 音频流唯一id。<br> 系统能力:SystemCapability.Multimedia.Audio.Renderer|
| uid | number | 是 | 表示应用ID。<br> **系统能力:** SystemCapability.Multimedia.Audio.Core|
| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 否 | 表示渲染器信息。<br> **系统能力:** SystemCapability.Multimedia.Audio.Renderer|
| rendererId | number | 否 | 音频流唯一id。<br> **系统能力:** SystemCapability.Multimedia.Audio.Renderer|
**示例:**
......@@ -4441,7 +4475,7 @@ audioRenderer.on('interrupt', async(interruptEvent) => {
### on('markReach')<sup>8+</sup>
on(type: "markReach", frame: number, callback: Callback<number>): void
on(type: "markReach", frame: number, callback: Callback&lt;number&gt;): void
订阅到达标记的事件。 当渲染的帧数达到 frame 参数的值时,回调被调用。
......@@ -4488,7 +4522,7 @@ audioRenderer.off('markReach');
### on('periodReach') <sup>8+</sup>
on(type: "periodReach", frame: number, callback: Callback<number>): void
on(type: "periodReach", frame: number, callback: Callback&lt;number&gt;): void
订阅到达标记的事件。 当渲染的帧数达到 frame 参数的值时,回调被循环调用。
......@@ -5067,7 +5101,7 @@ audioCapturer.getBufferSize().then((data) => {
### on('markReach')<sup>8+</sup>
on(type: "markReach", frame: number, callback: Callback<number>): void
on(type: "markReach", frame: number, callback: Callback&lt;number&gt;): void
订阅标记到达的事件。 当采集的帧数达到 frame 参数的值时,回调被触发。
......@@ -5113,7 +5147,7 @@ audioCapturer.off('markReach');
### on('periodReach')<sup>8+</sup>
on(type: "periodReach", frame: number, callback: Callback<number>): void
on(type: "periodReach", frame: number, callback: Callback&lt;number&gt;): void
订阅到达标记的事件。 当采集的帧数达到 frame 参数的值时,回调被循环调用。
......
......@@ -13,6 +13,8 @@ LauncherAbilityInfo信息
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:**此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------------- | ---------------------------------------------------- | ---- | ---- | ------------------------------------ |
| applicationInfo | [ApplicationInfo](js-apis-bundle-ApplicationInfo.md) | 是 | 否 | launcher ability的应用程序的配置信息 |
......
......@@ -4513,7 +4513,7 @@ on(type: 'metadataObjectsAvailable', callback: AsyncCallback<Array<MetadataObjec
**参数:**
| 名称 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------------------- - | ---- | ------------------------------------ |
| -------- | ------------------------------------------------ | ---- | ------------------------------------ |
| type | string | 是 | 监听事件,固定为'metadataObjectsAvailable',即metadata对象。 |
| callback | Callback<Array<[MetadataObject](#metadataobject)\>\> | 是 | 回调函数,用于获取错误信息。 |
......
......@@ -825,7 +825,7 @@ on(type: 'change', callback: Callback&lt;{ key : string }&gt;): void
```js
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to Gget preferences.");
console.info("Failed to get preferences.");
return;
}
var observer = function (key) {
......@@ -871,7 +871,7 @@ off(type: 'change', callback?: Callback&lt;{ key : string }&gt;): void
```js
data_preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) {
console.info("Failed to Gget preferences.");
console.info("Failed to get preferences.");
return;
}
var observer = function (key) {
......
......@@ -57,7 +57,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
let storage = data_storage.getStorageSync(path + '/mystore');
storage.putSync('startup', 'auto');
......@@ -90,7 +90,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
data_storage.getStorage(path + '/mystore', function (err, storage) {
if (err) {
......@@ -133,7 +133,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
let getPromise = data_storage.getStorage(path + '/mystore');
getPromise.then((storage) => {
......@@ -169,7 +169,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
data_storage.deleteStorageSync(path + '/mystore');
});
......@@ -199,7 +199,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
data_storage.deleteStorage(path + '/mystore', function (err) {
if (err) {
......@@ -241,7 +241,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
let promisedelSt = data_storage.deleteStorage(path + '/mystore');
promisedelSt.then(() => {
......@@ -275,7 +275,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
data_storage.removeStorageFromCacheSync(path + '/mystore');
});
......@@ -306,7 +306,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
data_storage.removeStorageFromCache(path + '/mystore', function (err) {
if (err) {
......@@ -348,7 +348,7 @@ var path;
var context = featureAbility.getContext();
context.getFilesDir().then((filePath) => {
path = filePath;
console.info("======================>getFilesDirPromsie====================>");
console.info("======================>getFilesDirPromise====================>");
let promiserevSt = data_storage.removeStorageFromCache(path + '/mystore')
promiserevSt.then(() => {
......
......@@ -13,8 +13,10 @@
**系统能力**: 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework
**系统API:**此接口为系统接口,三方应用不支持调用
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | ------ | ---- | ---- | ------------------------ |
| verison | string | 是 | 否 | 包含dispatchInfo版本信息 |
| version | string | 是 | 否 | 包含dispatchInfo版本信息 |
| dispatchAPI | string | 是 | 否 | 包含免安装接口版本号 |
......@@ -314,21 +314,21 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCa
let kvStore;
let kvManager;
const options = {
createIfMissing : true,
encrypt : false,
backup : false,
autoSync : true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '',
securityLevel : distributedData.SecurityLevel.S2,
}
try {
createIfMissing: true,
encrypt: false,
backup: false,
autoSync: true,
kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema: '',
securityLevel: distributedData.SecurityLevel.S2,
}
try {
kvManager.getKVStore('storeId', options, async function (err, store) {
console.log('getKVStore success');
kvStore = store;
kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) {
console.log('closeKVStore success');
});
console.log('getKVStore success');
kvStore = store;
kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) {
console.log('closeKVStore success');
});
});
} catch (e) {
console.log('closeKVStore e ' + e);
......@@ -364,29 +364,29 @@ closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise&lt;void&
let kvManager;
let kvStore;
const options = {
createIfMissing : true,
encrypt : false,
backup : false,
autoSync : true,
kvStoreType : distributedData.KVStoreType.SINGLE_VERSION,
schema : '',
securityLevel : distributedData.SecurityLevel.S2,
createIfMissing: true,
encrypt: false,
backup: false,
autoSync: true,
kvStoreType: distributedData.KVStoreType.SINGLE_VERSION,
schema: '',
securityLevel: distributedData.SecurityLevel.S2,
}
try {
try {
kvManager.getKVStore('storeId', options).then(async (store) => {
console.log('getKVStore success');
kvStore = store;
kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => {
console.log('closeKVStore success');
}).catch((err) => {
console.log('closeKVStore err ' + JSON.stringify(err));
});
console.log('getKVStore success');
kvStore = store;
kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => {
console.log('closeKVStore success');
}).catch((err) => {
console.log('closeKVStore err ' + JSON.stringify(err));
});
}).catch((err) => {
console.log('CloseKVStore getKVStore err ' + JSON.stringify(err));
});
} catch (e) {
} catch (e) {
console.log('closeKVStore e ' + e);
}
}
```
......@@ -576,7 +576,6 @@ on(event: 'distributedDataServiceDie', deathCallback: Callback&lt;void&gt;): voi
```js
let kvManager;
try {
console.log('KVManagerOn');
const deathCallback = function () {
console.log('death callback call');
......
......@@ -67,7 +67,7 @@ createColorPicker(source: image.PixelMap): Promise\<ColorPicker>
| 类型 | 说明 |
| ---------------------- | -------------- |
| Promisse\<[ColorPicker](#colorpicker)> | Promise对象。返回创建的ColorPicker实例。 |
| Promise\<[ColorPicker](#colorpicker)> | Promise对象。返回创建的ColorPicker实例。 |
**示例:**
......
......@@ -405,7 +405,7 @@ resolvedOptions(): NumberOptions
| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol",&nbsp;"narrowSymbol",&nbsp;"code",&nbsp;"name"。 |
| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 |
| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long",&nbsp;"short",&nbsp;"narrow"。 |
| unitUsage<sup>8+</sup> | string | 是 | 是 | 单位的使用场景,取值包括:"default",&nbsp;"area-land-agricult",&nbsp;"area-land-commercl",&nbsp;"area-land-residntl",&nbsp;"length-person",&nbsp;"length-person-small",&nbsp;"length-rainfall",&nbsp;"length-road",&nbsp;"length-road-small",&nbsp;"length-snowfall",&nbsp;"length-vehicle",&nbsp;"length-visiblty",&nbsp;"length-visiblty-small",&nbsp;"length-person-informal",&nbsp;"length-person-small-informal",&nbsp;"length-road-informal",&nbsp;"speed-road-travel",&nbsp;"speed-wind",&nbsp;"temperature-person",&nbsp;"temperature-weather",&nbsp;"volume-vehicle-fuel"。 |
| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default",&nbsp;"area-land-agricult",&nbsp;"area-land-commercl",&nbsp;"area-land-residntl",&nbsp;"length-person",&nbsp;"length-person-small",&nbsp;"length-rainfall",&nbsp;"length-road",&nbsp;"length-road-small",&nbsp;"length-snowfall",&nbsp;"length-vehicle",&nbsp;"length-visiblty",&nbsp;"length-visiblty-small",&nbsp;"length-person-informal",&nbsp;"length-person-small-informal",&nbsp;"length-road-informal",&nbsp;"speed-road-travel",&nbsp;"speed-wind",&nbsp;"temperature-person",&nbsp;"temperature-weather",&nbsp;"volume-vehicle-fuel"。 |
| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto",&nbsp;"never",&nbsp;"always",&nbsp;"expectZero"。 |
| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long",&nbsp;"short"。 |
| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard",&nbsp;"scientific",&nbsp;"engineering",&nbsp;"compact"。 |
......
......@@ -96,7 +96,7 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode'
| KEYCODE_EQUALS | number | 是 | 否 | 按键'=' |
| KEYCODE_LEFT_BRACKET | number | 是 | 否 | 按键'[' |
| KEYCODE_RIGHT_BRACKET | number | 是 | 否 | 按键']' |
| KEYCODE_BACKSLASH | number | 是 | 否 | 按键'\' |
| KEYCODE_BACKSLASH | number | 是 | 否 | 按键'\\' |
| KEYCODE_SEMICOLON | number | 是 | 否 | 按键';' |
| KEYCODE_APOSTROPHE | number | 是 | 否 | 按键''' (单引号) |
| KEYCODE_SLASH | number | 是 | 否 | 按键'/' |
......@@ -346,4 +346,4 @@ import {KeyCode} from '@ohos.multimodalInput.keyCode'
| KEYCODE_BTN_6 | number | 是 | 否 | 按键6 |
| KEYCODE_BTN_7 | number | 是 | 否 | 按键7 |
| KEYCODE_BTN_8 | number | 是 | 否 | 按键8 |
| KEYCODE_BTN_9 | number | 是 | 否 | 按键9 |
\ No newline at end of file
| KEYCODE_BTN_9 | number | 是 | 否 | 按键9 |
......@@ -112,7 +112,7 @@ off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback&lt;numbe
```js
var callback = (data) => {
console.info('Unegister the callback for screen changes. Data: ' + JSON.stringify(data))
console.info('Unregister the callback for screen changes. Data: ' + JSON.stringify(data))
};
screen.off("connect", callback);
```
......
......@@ -303,6 +303,8 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, call
将数据项名称及数据项的值保存到数据库中。使用callback异步回调。
**系统接口**:此接口为系统接口。
**系统能力**:SystemCapability.Applications.settings.Core
**参数**
......@@ -333,6 +335,8 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Pro
将数据项名称及数据项的值保存到数据库中。使用Promise异步回调。
**系统接口**:此接口为系统接口。
**系统能力**:SystemCapability.Applications.settings.Core
**参数**
......@@ -392,7 +396,7 @@ enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
## settings.enableAirplaneMode
enableAirplaneMode(enable: boolean): Promise<void>
enableAirplaneMode(enable: boolean): Promise\<void>
启用或禁用飞行模式。使用Promise异步回调。
......
......@@ -92,7 +92,7 @@ getCurrentTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
| isNano | boolean | | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
**示例:**
......@@ -120,7 +120,6 @@ getCurrentTime(callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
**示例:**
......@@ -148,7 +147,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
**返回值:**
......@@ -179,7 +178,7 @@ getRealActiveTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| isNano | boolean | 是 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来经过的时间,但不包括度睡眠时间。 |
**示例:**
......@@ -207,7 +206,6 @@ getRealActiveTime(callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来经过的时间,但不包括度睡眠时间。 |
**示例:**
......@@ -235,7 +233,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
**返回值:**
......@@ -266,7 +264,7 @@ getRealTime(isNano: boolean, callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| isNano | boolean | 是 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。 |
**示例:**
......@@ -294,7 +292,6 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来经过的时间,包括深度睡眠时间。 |
**示例:**
......@@ -321,7 +318,7 @@ getRealTime(isNano?: boolean): Promise&lt;number&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------- | ---- | ------------------------------------------------------------ |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br/>- false:毫秒数。 <br/> |
| isNano | boolean | 否 | 返回结果是否为纳秒数。 - true:纳秒数。 <br>- false:毫秒数。 <br> |
**返回值:**
......
......@@ -3118,7 +3118,7 @@ let promise = windowClass.setForbidSplitMove(isForbidSplitMove);
promise.then((data)=> {
console.info('Succeeded in forbidding window moving in split screen mode. Data: ' + JSON.stringify(data));
}).catch((err)=>{
console.error('Failed to forbidd window moving in split screen mode. Cause: ' + JSON.stringify(err));
console.error('Failed to forbid window moving in split screen mode. Cause: ' + JSON.stringify(err));
});
```
......
......@@ -301,7 +301,7 @@ var strXml =
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var arrayBuffer = new ArrayBuffer(strXml.length);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
......@@ -335,7 +335,7 @@ var strXml =
' <todo>Work</todo>' +
' <todo>Play</todo>' +
'</note>';
var arrayBuffer = new ArrayBuffer(strXml.length*2);
var arrayBuffer = new ArrayBuffer(strXml.length);
var bufView = new Uint8Array(arrayBuffer);
var strLen = strXml.length;
for (var i = 0; i < strLen; ++i) {
......@@ -358,7 +358,7 @@ console.log(str);
// key:0 value:0key:2 value:1key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:10 value:1key:2 value:2key:4 value:2key:3 value:2key:3 value:1key:1 value:0
// 解析:
// key代表了当前事件类型,value为当前解析的深度。你可以根据EVENTTYPE来知道具体的解析事件。例如本示例结果key: value代表含义为:
// 0(START_DOCUMENT):0(起始深度为0), 2(START_TAG):1(解析到开始标签node, 对应深度为1), 10(WHITESPACE):1(解析到空白标签空格, 对应深度为1), 2(START_TAG):2(解析到开始标签title, 对应深度为1), ...
// 0(START_DOCUMENT):0(起始深度为0), 2(START_TAG):1(解析到开始标签node, 对应深度为1), 10(WHITESPACE):1(解析到空白标签空格, 对应深度为1), 2(START_TAG):2(解析到开始标签title, 对应深度为2), ...
```
......
......@@ -10,24 +10,24 @@
在非折行flex布局基础上,增加了显示优先级标记,可以调整组件内元素水平/垂直方向的显示优先级,根据当前组件容器的可用空间来显示内容。
| 样式 | 类型 | 默认值 | 说明 |
| -------- | -------- | -------- | -------- |
| display-index | number | 0 | 适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。 |
| 样式 | 类型 | 说明 |
| -------- | -------- | -------- |
| display-index | number | 适用于div等支持flex布局的容器组件中的子组件,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏。<br/>默认值:0(表示不隐藏) |
## 占比能力
在非折行的flex布局中,定义了占比能力的组件,保证指定元素始终在容器的某一个比例空间中进行布局。
在非折行的flex布局中,定义了占比能力的组件,保证指定组件始终在容器的某一个比例空间中进行布局。
| 样式 | 类型 | 默认值 | 说明 |
| -------- | -------- | -------- | -------- |
| flex-weight | number | - | 指明当前元素在flex主轴方向上尺寸权值。如果容器组件中所有节点均设置此属性,当前元素尺寸为:&nbsp;容器主轴尺寸&nbsp;\*&nbsp;当前权值&nbsp;/&nbsp;所有子元素权值和。如果容器组件中某几个节点设置此属性,则容器会对其他未设置此属性的节点进行布局,再将剩余空间分配给设置了此属性的节点。设置了此属性的节点的尺寸为:容器剩余空间&nbsp;\*&nbsp;该元素权值&nbsp;/&nbsp;所有子元素权值和。 |
| 样式 | 类型 | 说明 |
| -------- | -------- | -------- |
| flex-weight | number | 指明当前元素在flex主轴方向上尺寸权值。如果容器组件中所有节点均设置此属性,当前元素尺寸为:&nbsp;容器主轴尺寸&nbsp;\*&nbsp;当前权值&nbsp;/&nbsp;所有子元素权值和。如果容器组件中某几个节点设置此属性,则容器会对其他未设置此属性的节点进行布局,再将剩余空间分配给设置了此属性的节点,如果未设置此属性的节点设置了超过父元素的宽度,那么将没有剩余空间分配给设置了此属性的节点。设置了此属性的节点的尺寸为:容器剩余空间&nbsp;\*&nbsp;该元素权值&nbsp;/&nbsp;所有子元素权值和。 |
## 固定比例
定义了组件固定比例调整尺寸的能力。
| 样式 | 类型 | 默认值 | 说明 |
| -------- | -------- | -------- | -------- |
| aspect-ratio | number | - | 1.&nbsp;接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。<br/>2.&nbsp;遵守最大值与最小值的限制。<br/>3.&nbsp;在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 |
| 样式 | 类型 | 说明 |
| -------- | -------- | -------- |
| aspect-ratio | number | 1.&nbsp;接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。<br/>2.&nbsp;遵守最大值与最小值的限制。<br/>3.&nbsp;在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 |
......@@ -20,9 +20,9 @@
除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| label | Label | - | 否 | 自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用“返回”和“下一步”文本按钮,在非中文语言环境下,使用“BACK”和“NEXT”文本按钮。针对第一个步骤,没有回退文本按钮,针对最后一个步骤,下一步文本按钮文本使用“开始”(中文语言)或者“START”(非中文语言)。 |
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| label | Label | &nbsp;&nbsp;&nbsp;&nbsp; | 自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用"返回"和"下一步"文本按钮,在非中文语言环境下,使用"BACK"和"NEXT"文本按钮。针对第一个步骤,没有"返回"文本按钮;针对最后一个步骤,"下一步"文本按钮文本使用"开始"(中文语言)或者"START"(非中文语言)。 |
**表1** Label对象定义
......
......@@ -19,9 +19,9 @@
除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| scrollable | boolean | true | 否 | 是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。 |
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| scrollable | boolean | &nbsp;&nbsp;&nbsp;&nbsp; | 是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。 |
## 样式
......
......@@ -26,19 +26,19 @@
支持以下表格中的属性。
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------------- | ---------------------------------- | ----- | ---- | ---------------------------------------- |
| id | string | - | 否 | 组件的唯一标识。 |
| path | string | 0 | 是 | 设置路径的形状。<br/>字母指令表示的意义如下:<br/>-&nbsp;M&nbsp;=&nbsp;moveto<br/>-&nbsp;L&nbsp;=&nbsp;lineto<br/>-&nbsp;H&nbsp;=&nbsp;horizontal&nbsp;lineto<br/>-&nbsp;V&nbsp;=&nbsp;vertical&nbsp;lineto<br/>-&nbsp;C&nbsp;=&nbsp;curveto<br/>-&nbsp;S&nbsp;=&nbsp;smooth&nbsp;curveto<br/>-&nbsp;Q&nbsp;=&nbsp;quadratic&nbsp;Belzier&nbsp;curve<br/>-&nbsp;T&nbsp;=&nbsp;smooth&nbsp;quadratic&nbsp;Belzier&nbsp;curveto<br/>-&nbsp;A&nbsp;=&nbsp;elliptical&nbsp;Arc<br/>-&nbsp;Z&nbsp;=&nbsp;closepath |
| startOffset | &lt;length&gt;\|&lt;percentage&gt; | 0 | 否 | 设置文本沿path绘制的起始偏移。 |
| font-size | &lt;length&gt; | 30px | 否 | 设置文本的尺寸。 |
| fill | &lt;color&gt; | black | 否 | 字体填充颜色 |
| by | number | - | 否 | 相对被指定动画的属性偏移值,from默认为原属性值。 |
| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 |
| fill-opacity | number | 1.0 | 否 | 字体填充透明度 |
| stroke | &lt;color&gt; | black | 否 | 绘制字体边框并指定颜色 |
| stroke-width | number | 1px | 否 | 字体边框宽度 |
| stroke-opacity | number | 1.0 | 否 | 字体边框透明度 |
| 名称 | 类型 | 默认值 | 描述 |
| -------------- | ---------------------------------- | ------ | ------------------------------------------------------------ |
| id | string | - | 组件的唯一标识。 |
| path | string | 0 | 设置路径的形状。<br/>字母指令表示的意义如下:<br/>-&nbsp;M&nbsp;=&nbsp;moveto<br/>-&nbsp;L&nbsp;=&nbsp;lineto<br/>-&nbsp;H&nbsp;=&nbsp;horizontal&nbsp;lineto<br/>-&nbsp;V&nbsp;=&nbsp;vertical&nbsp;lineto<br/>-&nbsp;C&nbsp;=&nbsp;curveto<br/>-&nbsp;S&nbsp;=&nbsp;smooth&nbsp;curveto<br/>-&nbsp;Q&nbsp;=&nbsp;quadratic&nbsp;Belzier&nbsp;curve<br/>-&nbsp;T&nbsp;=&nbsp;smooth&nbsp;quadratic&nbsp;Belzier&nbsp;curveto<br/>-&nbsp;A&nbsp;=&nbsp;elliptical&nbsp;Arc<br/>-&nbsp;Z&nbsp;=&nbsp;closepath<br/>默认值:0 |
| startOffset | &lt;length&gt;\|&lt;percentage&gt; | 0 | 设置文本沿path绘制的起始偏移。<br/>默认值:0 |
| font-size | &lt;length&gt; | 30px | 设置文本的尺寸。<br/>默认值:30px |
| fill | &lt;color&gt; | black | 字体填充颜色。<br/>默认值:black |
| by | number | - | 相对被指定动画的属性偏移值,from默认为原属性值。 |
| opacity | number | 1 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。<br/>默认值:0 |
| fill-opacity | number | 1.0 | 字体填充透明度。<br/>默认值:1.0 |
| stroke | &lt;color&gt; | black | 绘制字体边框并指定颜色。<br/>默认值:balck |
| stroke-width | number | 1px | 字体边框宽度。<br/>默认值:1px |
| stroke-opacity | number | 1.0 | 字体边框透明度。<br/>默认值:1.0 |
## 示例
......
# Progress
进度条,用于显示内容加载或操作处理进度。
进度条组件,用于显示内容加载或操作处理等进度。
> **说明:**
>
......@@ -24,27 +24,36 @@ Progress(options: {value: number, total?: number, type?: ProgressType})
| -------- | -------- | -------- | -------- |
| value | number | 是 | 指定当前进度值。 |
| total | number | 否 | 指定进度总长。<br/>默认值:100 |
| type | ProgressType | 否 | 指定进度条样式。<br/>默认值:ProgressType.Linear |
| type<sup>8+</sup> | ProgressType | 否 | 指定进度条样式。<br/>默认值:ProgressType.Linear |
| style<sup>deprecated</sup> | ProgressStyle | 否 | 指定进度条类型。<br/>该参数从API Version8开始废弃,建议使用type替代。<br/>默认值:ProgressStyle.Linear |
## ProgressType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Linear<sup>8+</sup> | 线性样式。 |
| Ring<sup>8+</sup> | 环形无刻度样式,环形圆环逐渐填充完成过程。 |
| Eclipse<sup>8+</sup> | 圆形样式,展现类似月圆月缺的进度展示效果,从月牙逐渐到满月的这个过程代表了下载的进度。 |
| ScaleRing<sup>8+</sup> | 环形有刻度样式,类似时钟刻度形式加载进度。 |
| Capsule<sup>8+</sup> | 胶囊样式,头尾两端处,进度条由弧形变成直线和直线变成弧形的过程;中段处,进度条正常往右走的过程。 |
| Linear | 线性样式。 |
| Ring<sup>8+</sup> | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 |
| Eclipse<sup>8+</sup> | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 |
| ScaleRing<sup>8+</sup> | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 |
| Capsule<sup>8+</sup> | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 |
## ProgressStyle枚举说明
| 名称 | 描述 |
| --------- | ------------------------------------------------------------ |
| Linear | 线性样式。 |
| Ring | 环形无刻度样式,环形圆环逐渐显示至完全填充效果。 |
| Eclipse | 圆形样式,显示类似月圆月缺的进度展示效果,从月牙逐渐变化至满月。 |
| ScaleRing | 环形有刻度样式,显示类似时钟刻度形式的进度展示效果。 |
| Capsule | 胶囊样式,头尾两端圆弧处的进度展示效果与Eclipse相同;中段处的进度展示效果与Linear相同。 |
## 属性
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| value | number | 设置当前进度值。 |
| color | [ResourceColor](../../ui/ts-types.md) | 设置进度条前景色。 |
| style<sup>8+</sup> | {<br/>strokeWidth?:&nbsp;[Length](../../ui/ts-types.md),<br/>scaleCount?:&nbsp;number,<br/>scaleWidth?:&nbsp;[Length](../../ui/ts-types.md)<br/>} | 定义组件的样式。<br/>strokeWidth:&nbsp;设置进度条宽度。<br/>scaleCount:&nbsp;设置环形进度条总刻度数。<br/>scaleWidth:&nbsp;设置环形进度条刻度粗细。刻度粗细大于进度条宽度时,刻度粗细为系统默认粗细。 |
| style<sup>8+</sup> | {<br/>strokeWidth?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>scaleCount?:&nbsp;number,<br/>scaleWidth?:&nbsp;[Length](../../ui/ts-types.md#length)<br/>} | 定义组件的样式。<br/>-&nbsp;strokeWidth:&nbsp;设置进度条宽度。<br/>-&nbsp;scaleCount:&nbsp;设置环形进度条总刻度数。<br/>-&nbsp;scaleWidth:&nbsp;设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 |
## 示例
......
......@@ -3,12 +3,8 @@
提供在给定范围内选择评分的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -16,24 +12,25 @@
## 接口说明
## 接口
Rating(options?: { rating: number, indicator?: boolean })
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| rating | number | 是 | 0 | 设置并接收评分值。 |
| indicator | boolean | 否 | false | 仅作为指示器使用,不可操作。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| rating | number | 是 | 设置并接收评分值。<br/>默认值:0 |
| indicator | boolean | 否 | 仅作为指示器使用,不可操作。<br/>默认值: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 | 设置评星总数。<br/>默认值:5 |
| stepSize | number | 操作评级的步长。<br/>默认值:0.5 |
| starStyle | {<br/>backgroundUri:&nbsp;string,<br/>foregroundUri:&nbsp;string,<br/>secondaryUri?:&nbsp;string<br/>} | backgroundUri:未选中的星级的图片链接,可由用户自定义或使用系统默认图片,仅支持本地图片。<br/>foregroundUri:选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。<br/>secondaryUir:部分选中的星级的图片路径,可由用户自定义或使用系统默认图片,仅支持本地图片。 |
## 事件
......
# ScrollBar
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
滚动条组件ScrollBar,用于配合可滚动组件使用,如List、Grid、Scroll。
## 权限列表
> **说明:**
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -21,23 +16,25 @@
ScrollBar(value: { scroller: Scroller, direction?: ScrollBarDirection, state?: BarState })
- ScrollBarOptions的参数描述
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | - | 可滚动组件的控制器。用于与可滚动组件进行绑定。 |
| direction | ScrollBarDirection | 否 | ScrollBarDirection.Vertical | 滚动条的方向,控制可滚动组件对应方向的滚动。 |
| state | [BarState](ts-appendix-enums.md#barstate) | 否 | BarState.Auto | 滚动条状态。 |
> **说明:**
> ScrollBar组件负责定义可滚动区域的行为样式,ScrollBar的子节点负责定义滚动条的行为样式。
>
> 滚动条组件与可滚动组件通过Scroller进行绑定,且只有当两者方向相同时,才能联动,ScrollBar与可滚动组件仅支持一对一绑定。
- ScrollBarDirection枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Vertical | 纵向滚动条。 |
| Horizontal | 横向滚动条。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | 是 | 可滚动组件的控制器。用于与可滚动组件进行绑定。 |
| direction | ScrollBarDirection | 否 | 滚动条的方向,控制可滚动组件对应方向的滚动。<br/>默认值:ScrollBarDirection.Vertical |
| state | [BarState](ts-appendix-enums.md#barstate) | 否 | 滚动条状态。<br/>默认值:BarState.Auto |
> **说明:**
> ScrollBar组件负责定义可滚动区域的行为样式,ScrollBar的子节点负责定义滚动条的行为样式。
>
> 滚动条组件与可滚动组件通过Scroller进行绑定,且只有当两者方向相同时,才能联动,ScrollBar与可滚动组件仅支持一对一绑定。
## ScrollBarDirection枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Vertical | 纵向滚动条。 |
| Horizontal | 横向滚动条。 |
## 示例
......
# Select
> **说明:** 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
提供下拉选择菜单,可以让用户在多个选项之间选择。
## 权限列表
> **说明:**
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -18,25 +16,25 @@ Select(options: Array\<SelectOption\>)
**SelectOption对象说明:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ----------------------------------- | ---- | ---- | ------- |
| value | [ResourceStr](../../ui/ts-types.md) | 是 | - | 下拉选项内容。 |
| icon | [ResourceStr](../../ui/ts-types.md) | 否 | - | 下拉选项图片。 |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------ | ----------------------------------- | ---- | -------------- |
| value | [ResourceStr](../../ui/ts-types.md) | 是 | 下拉选项内容。 |
| icon | [ResourceStr](../../ui/ts-types.md) | 否 | 下拉选项图片。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| ----------------------- | ------------------------------------- | ---- | ------------------------ |
| selected | number | - | 设置下拉菜单初始选择项的索引,第一项的索引为0。 |
| value | string | - | 设置下拉按钮本身的文本显示。 |
| font | [Font](../../ui/ts-types.md) | - | 设置下拉按钮本身的文本样式: |
| fontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉按钮本身的文本颜色。 |
| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单选中项的背景色。 |
| selectedOptionFont | [Font](../../ui/ts-types.md) | - | 设置下拉菜单选中项的文本样式: |
| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单选中项的文本颜色。 |
| optionBgColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单项的背景色。 |
| optionFont | [Font](../../ui/ts-types.md) | - | 设置下拉菜单项的文本样式: |
| optionFontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置下拉菜单项的文本颜色。 |
| 名称 | 参数类型 | 描述 |
| ----------------------- | ------------------------------------- | --------------------------------------------- |
| selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。 |
| value | string | 设置下拉按钮本身的文本显示。 |
| font | [Font](../../ui/ts-types.md) | 设置下拉按钮本身的文本样式。 |
| fontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉按钮本身的文本颜色。 |
| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的背景色。 |
| selectedOptionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单选中项的文本样式。 |
| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的文本颜色。 |
| optionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的背景色。 |
| optionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单项的文本样式。 |
| optionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的文本颜色。 |
## 事件
......
......@@ -4,12 +4,8 @@
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -24,19 +20,20 @@ StepperItem()
## 属性
| 参数名 | 参数类型 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- |
| prevLabel | string | - | 当步骤导航器大于一页,除第一页默认值都为"返回"。 |
| nextLabel | string | - | 步骤导航器大于一页时,最后一页默认值为"开始",其余页默认值为"下一步"。 |
| status | ItemState | ItemState.Normal | 步骤导航器元素的状态。 |
- ItemState枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 |
| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 |
| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 |
| Skip | 跳过状态,表示跳过当前步骤,&nbsp;进入下一个StepperItem。 |
| 参数名 | 参数类型 | 参数描述 |
| -------- | -------- | -------- |
| prevLabel | string | 当步骤导航器大于一页,除第一页默认值都为“返回”。 |
| nextLabel | string | 步骤导航器大于一页时,最后一页默认值为“开始”,其余页默认值为“下一步”。 |
| status | ItemState | 步骤导航器元素的状态。<br/>默认值:ItemState.Normal |
## ItemState枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Normal | 正常状态,右侧文本按钮正常显示,可点击进入下一个StepperItem。 |
| Disabled | 不可用状态,右侧文本按钮灰度显示,不可点击进入下一个StepperItem。 |
| Waiting | 等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个StepperItem。 |
| Skip | 跳过状态,表示跳过当前步骤,&nbsp;进入下一个StepperItem。 |
## 示例
......
......@@ -42,7 +42,7 @@ TextClock(options?: { timeZoneOffset?: number, controller?: TextClockController
## TextClockController
TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。
TextClock容器组件的控制器,可以将此对象绑定到TextClock组件,再通过它控制文本时钟的启动与停止。一个TextClock组件仅支持绑定一个控制器。
### 导入对象
......
......@@ -43,7 +43,7 @@ TextTimer(options: { isCountDown?: boolean, count?: number, controller?: TextTim
## TextTimerController
TextTimer组件的控制器,用于控制文本计时器。
TextTimer组件的控制器,用于控制文本计时器。一个TextTimer组件仅支持绑定一个控制器。
### 导入对象
......
......@@ -32,7 +32,7 @@ Canvas(context?: CanvasRenderingContext2D)
| 名称 | 参数 | 描述 |
| ----------------------------- | ---- | -------------------- |
| onReady(event: () => void) | 无 | 画布组件的事件回调,可以在此时进行绘制。 |
| onReady(event: () => void) | 无 | Canvas组件初始化完成时的事件回调,该事件之后Canvas组件宽高确定且可获取,可使用Canvas相关API进行绘制。 |
## 示例
......
......@@ -34,7 +34,7 @@ Grid(scroller?: Scroller)
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | BarState.Off | 设置滚动条状态。 |
| scrollBarColor | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Color](ts-appendix-enums.md#color) | - | 设置滚动条的颜色。 |
| scrollBarWidth | number&nbsp;\|&nbsp;string | - | 设置滚动条的宽度。 |
| cachedCount | number | 1 | 设置预加载的GridItem的数量。 |
| cachedCount | number | 1 | 设置预加载的GridItem的数量。具体使用可参考[减少应用白块说明](../../ui/ts-performance-improvement-recommendation.md#减少应用滑动白块) |
| editMode <sup>8+</sup> | boolean | false | 是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部[GridItem](ts-container-griditem.md)。 |
| layoutDirection<sup>8+</sup> | [GridDirection](#griddirection8枚举说明) | GridDirection.Row | 设置布局的主轴方向。 |
| maxCount<sup>8+</sup> | number | 1 | 当layoutDirection是Row/RowReverse时,表示可显示的最大行数<br/>当layoutDirection是Column/ColumnReverse时,表示可显示的最大列数。 |
......
......@@ -34,7 +34,7 @@ List(value?: {initialIndex?: number, space?: number | string, scroller?: Scrolle
| listDirection | [Axis](ts-appendix-enums.md#axis) | Axis.Vertical | 设置List组件排列方向参照Axis枚举说明。 |
| divider | {<br/>strokeWidth:&nbsp;Length,<br/>color?:[ResourceColor](../../ui/ts-types.md),<br/>startMargin?:&nbsp;Length,<br/>endMargin?:&nbsp;Length<br/>} | - | 用于设置ListItem分割线样式,默认无分割线。<br/>strokeWidth:&nbsp;分割线的线宽。<br/>color:&nbsp;分割线的颜色。<br/>startMargin:&nbsp;分割线距离列表侧边起始端的距离。<br/>endMargin:&nbsp;分割线距离列表侧边结束端的距离。 |
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | BarState.Off | 设置滚动条状态。 |
| cachedCount | number | 1 | 设置预加载的ListItem的数量。 |
| cachedCount | number | 1 | 设置预加载的ListItem的数量。具体使用可参考[减少应用白块说明](../../ui/ts-performance-improvement-recommendation.md#减少应用滑动白块) |
| editMode | boolean | false | 声明当前List组件是否处于可编辑模式。 |
| edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | EdgeEffect.Spring | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。 |
| chainAnimation | boolean | false | 用于设置当前list是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的ListItem或ListItemGroup间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。其中ListItemGroup以一个整体参与链式联动动效,ListItemGroup内的ListITem不参与链式联动动效。<br/>-&nbsp;false:不启用链式联动。<br/>-&nbsp;true:启用链式联动。 |
......
# Navigator
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
路由容器组件,提供路由跳转能力。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -21,28 +16,28 @@
Navigator(value?: {target: string, type?: NavigationType})
创建路由组件。
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------ | -------------- | ---- | ---------------------------------------------- |
| target | string | 是 | 指定跳转目标页面的路径。 |
| type | NavigationType | 否 | 指定路由方式。<br/>默认值:NavigationType.Push |
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | -------------- | ---- | ------------------- | ------------ |
| target | string | 是 | - | 指定跳转目标页面的路径。 |
| type | NavigationType | 否 | NavigationType.Push | 指定路由方式。 |
## NavigationType枚举说明
- NavigationType枚举说明
| 名称 | 描述 |
| ------- | -------------------------- |
| Push | 跳转到应用内的指定页面。 |
| Replace | 用应用内的某个页面替换当前页面,并销毁被替换的页面。 |
| Back | 返回上一页面或指定的页面。 |
| 名称 | 描述 |
| ------- | -------------------------- |
| Push | 跳转到应用内的指定页面。 |
| Replace | 用应用内的某个页面替换当前页面,并销毁被替换的页面。 |
| Back | 返回上一页面或指定的页面。 |
## 属性
| 名称 | 参数 | 默认值 | 描述 |
| ------ | ------- | --------- | ---------------------------------------- |
| active | boolean | - | 当前路由组件是否处于激活状态,处于激活状态时,会生效相应的路由操作。 |
| params | Object | undefined | 跳转时要同时传递到目标页面的数据,可在目标页面使用router.getParams()获得。 |
| 名称 | 参数 | 描述 |
| ------ | ------- | ------------------------------------------------------------ |
| active | boolean | 当前路由组件是否处于激活状态,处于激活状态时,会生效相应的路由操作。 |
| params | Object | 跳转时要同时传递到目标页面的数据,可在目标页面使用router.getParams()获得。 |
## 示例
......
# Panel
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
可滑动面板,提供一种轻量的内容展示窗口,方便在不同尺寸中切换。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -19,47 +14,51 @@
## 接口
Panel(value:{show:boolean})
Panel(show:boolean)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| show | boolean | 是 | - | 控制Panel显示或隐藏。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| show | boolean | 是 | 控制Panel显示或隐藏。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| type | PanelType | PanelType.Foldable | 设置可滑动面板的类型。 |
| mode | PanelMode | - | 设置可滑动面板的初始状态。 |
| dragBar | boolean | true | 设置是否存在dragbar,true表示存在,false表示不存在。 |
| fullHeight | Length | - | 指定PanelMode.Full状态下的高度。 |
| halfHeight | Length | - | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 |
| miniHeight | Length | - | 指定PanelMode.Mini状态下的高度。 |
| backgroundMask<sup>9+</sup>|(color: ResourceColor)| - |指定Panel的背景蒙层。|
- PanelType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Minibar | 提供minibar和类全屏展示切换效果。 |
| Foldable | 内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。 |
| Temporary | 内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。 |
- PanelMode枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Mini | 类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。 |
| Half | 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。 |
| Full | 类全屏状态。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| type | PanelType | 设置可滑动面板的类型。<br/>默认值:PanelType.Foldable |
| mode | PanelMode | 设置可滑动面板的初始状态。 |
| dragBar | boolean | 设置是否存在dragbar,true表示存在,false表示不存在。<br/>默认值:true |
| fullHeight | string&nbsp;\|&nbsp;number | 指定PanelMode.Full状态下的高度。 |
| halfHeight | string&nbsp;\|&nbsp;number | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 |
| miniHeight | string&nbsp;\|&nbsp;number | 指定PanelMode.Mini状态下的高度。 |
| show | boolean | 当滑动面板弹出时调用。 |
| backgroundMask<sup>9+</sup>|[ResourceColor](../../ui/ts-types.md#resourcecolor8)|指定Panel的背景蒙层。|
## PanelType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Minibar | 提供minibar和类全屏展示切换效果。 |
| Foldable | 内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。 |
| Temporary | 内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。 |
## PanelMode枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Mini | 类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。 |
| Half | 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。 |
| Full | 类全屏状态。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onChange(callback:&nbsp;(width:&nbsp;number,&nbsp;height:&nbsp;number,&nbsp;mode:&nbsp;PanelMode)&nbsp;=&gt;&nbsp;void) | 当可滑动面板发生状态变化时触发,&nbsp;返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 |
| onHeightChange(callback: (value: number) => void)<sup>9+</sup> |当可滑动面板发生高度变化时触发,返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。因用户体验设计原因,panel最高只能滑到 fullHeight-8vp |
| onChange(event:&nbsp;(width:&nbsp;number,&nbsp;height:&nbsp;number,&nbsp;mode:&nbsp;PanelMode)&nbsp;=&gt;&nbsp;void) | 当可滑动面板发生状态变化时触发,&nbsp;返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 |
| onHeightChange(callback: (value: number) => void)<sup>9+</sup> |当可滑动面板发生高度变化时触发,返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。因用户体验设计原因,panel最高只能滑到 fullHeight-8vp |
## 示例
......
......@@ -3,11 +3,8 @@
可以进行页面下拉操作并显示刷新动效的容器组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -15,15 +12,15 @@
## 接口
Refresh\(value: \{ refreshing: boolean, offset?: Length, friction?: number | string \}\)
Refresh\(value: \{ refreshing: boolean, offset?: number&nbsp;|&nbsp;string , friction?: number | string \}\)
- 参数
**参数:**
| 参数 | 参数名 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| refreshing | boolean | 是 | - | 当前组件是否正在刷新。<br/>该参数支持[$$](../../ui/ts-syntactic-sugar.md)双向绑定变量。 |
| offset | Length | 否 | 16 | 刷新组件静止时距离父组件顶部的距离。|
| friction | number&nbsp;\|&nbsp;string | 否 | 62 | 下拉摩擦系数,取值范围为0到100。<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
| 参数 | 参数名 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| refreshing | boolean | 是 | 当前组件是否正在刷新。<br/>该参数支持[$$](../../ui/ts-syntactic-sugar.md)双向绑定变量。 |
| offset | string&nbsp;\|&nbsp;number | 否 | 刷新组件静止时距离父组件顶部的距离。<br/>默认值:16,单位vp |
| friction | number&nbsp;\|&nbsp;string | 否 | 下拉摩擦系数,取值范围为0到100。<br/>默认值:62<br/>-&nbsp;0表示下拉刷新容器不跟随手势下拉而下拉。<br/>-&nbsp;100表示下拉刷新容器紧紧跟随手势下拉而下拉。<br/>-&nbsp;数值越大,下拉刷新容器跟随手势下拉的反应越灵敏。 |
......@@ -32,18 +29,18 @@ Refresh\(value: \{ refreshing: boolean, offset?: Length, friction?: number | str
| 名称 | 描述 |
| -------- | -------- |
| onStateChange(callback: (state: RefreshStatus) => void)| 当前刷新状态变更时,触发回调。<br/>state:刷新状态。 |
| onStateChange(callback: (state: RefreshStatus) => void)| 当前刷新状态变更时,触发回调。<br/>-&nbsp;state:刷新状态。 |
| onRefreshing(callback: () => void)| 进入刷新状态时触发回调。 |
- RefreshStatus枚举说明
## RefreshStatus枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Inactive | 默认未下拉状态。 |
| Drag | 下拉中,下拉距离小于刷新距离。 |
| OverDrag | 下拉中,下拉距离超过刷新距离。 |
| Refresh | 下拉结束,回弹至刷新距离,进入刷新状态。 |
| Done | 刷新结束,返回初始状态(顶部)。 |
| 名称 | 描述 |
| -------- | -------- |
| Inactive | 默认未下拉状态。 |
| Drag | 下拉中,下拉距离小于刷新距离。 |
| OverDrag | 下拉中,下拉距离超过刷新距离。 |
| Refresh | 下拉结束,回弹至刷新距离,进入刷新状态。 |
| Done | 刷新结束,返回初始状态(顶部)。 |
## 示例
......
# Row
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
沿水平方向布局容器。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -19,20 +14,21 @@
## 接口
Row(value?:{space?: Length})
Row(value?:{space?: number&nbsp;|&nbsp;string })
**参数:**
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| space | Length | 否 | 0 | 横向布局元素间距。 |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| space | string&nbsp;\|&nbsp;number | 否 | 横向布局元素间距。<br/>默认值:0 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| alignItems | [VerticalAlign](ts-appendix-enums.md#verticalalign) | VerticalAlign.Center | 在垂直方向上子组件的对齐格式。 |
| justifyContent<sup>8+</sup> | [FlexAlign](ts-appendix-enums.md#flexalign) | FlexAlign.Start | 设置子组件在水平方向上的对齐格式。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| alignItems | [VerticalAlign](ts-appendix-enums.md#verticalalign) | 设置子组件在垂直方向上的对齐格式。<br/>默认值:VerticalAlign.Center |
| justifyContent<sup>8+</sup> | [FlexAlign](ts-appendix-enums.md#flexalign) | 设置子组件在水平方向上的对齐格式。<br/>FlexAlign.Start |
## 示例
......
# SideBarContainer
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
提供侧边栏可以显示和隐藏的侧边栏容器,通过子组件定义侧边栏和内容区,第一个子组件表示侧边栏,第二个子组件表示内容区。
## 权限列表
> **说明:**
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -21,52 +16,56 @@
SideBarContainer( type?: SideBarContainerType )
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| type | SideBarContainerType | 否 | SideBarContainerType.Embed | 设置侧边栏的显示类型。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| type | SideBarContainerType | 否 | 设置侧边栏的显示类型。<br/>默认值:SideBarContainerType.Embed |
- SideBarContainerType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Embed | 侧边栏嵌入到组件内,侧边栏和内容区并列显示。 |
| Overlay | 侧边栏浮在内容区上面。 |
## SideBarContainerType枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Embed | 侧边栏嵌入到组件内,和内容区并列显示。 |
| Overlay | 侧边栏浮在内容区上面。 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| showSideBar | boolean | 设置是否显示侧边栏。<br/>默认值:true |
| controlButton | ButtonStyle | 设置侧边栏控制按钮的属性。 |
| showControlButton | boolean | 设置是否显示控制按钮。<br/>默认值:true |
| sideBarWidth | number | 设置侧边栏的宽度。<br/>默认值:200,单位vp |
| minSideBarWidth | number | 设置侧边栏最小宽度。<br/>默认值:200,单位vp |
| maxSideBarWidth | number | 设置侧边栏最大宽度。<br/>默认值:280,单位vp |
| autoHide<sup>9+</sup> | boolean | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。<br/>默认值:true |
| sideBarPosition<sup>9+</sup> | SideBarPosition | 设置侧边栏显示位置。<br/>默认值:SideBarPosition.Start |
## ButtonStyle对象说明
| 名称 | 参数类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| showSideBar | boolean | true | 设置是否显示侧边栏。 |
| controlButton | ButtonStyle | - | 设置侧边栏控制按钮的属性。 |
| showControlButton | boolean | true | 设置是否显示控制按钮。 |
| sideBarWidth | number \| [Length<sup>9+</sup>](../../ui/ts-types.md#长度类型) | 200 | 设置侧边栏的宽度。 |
| minSideBarWidth | number \| [Length<sup>9+</sup>](../../ui/ts-types.md#长度类型) | 200 | 设置侧边栏最小宽度。 |
| maxSideBarWidth | number \| [Length<sup>9+</sup>](../../ui/ts-types.md#长度类型) | 280 | 设置侧边栏最大宽度。 |
| autoHide<sup>9+</sup> | boolean | true | 设置当侧边栏拖拽到小于最小宽度后,是否自动隐藏。 |
| sideBarPosition<sup>9+</sup> | SideBarPosition | SideBarPosition.Start | 设置侧边栏显示位置。 |
- ButtonStyle对象说明
| 名称 | 参数类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| left | number | 否 | 16 | 设置侧边栏控制按钮距离容器左界限的间距。 |
| top | number | 否 | 48 | 设置侧边栏控制按钮距离容器上界限的间距。 |
| width | number | 否 | 32 | 设置侧边栏控制按钮的宽度。 |
| height | number | 否 | 32 | 设置侧边栏控制按钮的高度。 |
| icons | {<br/>shown:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>hidden:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>switching?:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) <br/>} | 否 | - | 设置侧边栏控制按钮的图标:<br/> </p> - shown: 设置侧边栏显示时控制按钮的图标。<br>- hidden: 设置侧边栏隐藏时控制按钮的图标。<br>- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 |
- SideBarPosition<sup>9+</sup>枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Start | 侧边栏位于容器左侧。 |
| End | 侧边栏位于容器右侧。 |
| left | number | 否 | 设置侧边栏控制按钮距离容器左界限的间距。<br/>默认值:16,单位vp |
| top | number | 否 | 设置侧边栏控制按钮距离容器上界限的间距。<br/>默认值:48,单位vp |
| width | number | 否 | 设置侧边栏控制按钮的宽度。<br/>默认值:32,单位vp |
| height | number | 否 | 设置侧边栏控制按钮的高度。<br/>默认值:32,单位vp |
| icons | {<br/>shown:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>hidden:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) ,<br/>switching?:&nbsp;string \| PixelMap \| [Resource](../../ui/ts-types.md) <br/>} | 否 | 设置侧边栏控制按钮的图标:<br/> </p> - shown: 设置侧边栏显示时控制按钮的图标。<br>- hidden: 设置侧边栏隐藏时控制按钮的图标。<br>- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 |
## SideBarPosition<sup>9+</sup>枚举说明
| 名称 | 描述 |
| -------- | -------- |
| Start | 侧边栏位于容器左侧。 |
| End | 侧边栏位于容器右侧。 |
## 事件
| 名称 | 功能描述 |
| 名称 | 功能描述 |
| -------- | -------- |
| onChange(callback: (value: boolean) =&gt; void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。<p> value的true表示显示,false表示隐藏。|
| onChange(callback: (value: boolean) =&gt; void) | 当侧边栏的状态在显示和隐藏之间切换时触发回调。<p> true表示显示,false表示隐藏。 |
## 示例
......
# Stack
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -19,12 +14,13 @@
## 接口
Stack(value:{alignContent?: Alignment})
Stack({&nbsp;alignContent?:&nbsp;Alignment&nbsp;})
**参数:**
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| alignContent | [Alignment](ts-appendix-enums.md#alignment枚举说明) | 否 | Center | 设置子组件在容器内的对齐方式。 |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| alignContent | [Alignment](ts-appendix-enums.md#alignment) | 否 | 设置子组件在容器内的对齐方式。<br/>默认值:Alignment.Center |
## 示例
......
# Swiper
滑块视图容器,提供子组件滑动轮播显示的能力。
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
滑动容器,提供切换子组件显示的能力。
## 权限列表
## 子组件
可以包含子组件。
......@@ -24,14 +18,14 @@ Swiper(value:{controller?: SwiperController})
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ------------------------------------- | ---- | -------------------- |
| controller | [SwiperController](#swipercontroller) | 否 | 给组件绑定一个控制器,用来控制组件翻页。<br/>默认值:null |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ------------------------------------- | ---- | -------------------- |
| controller | [SwiperController](#swipercontroller) | 否 | 给组件绑定一个控制器,用来控制组件翻页。 |
## 属性
不支持[Menu控制](ts-universal-attributes-menu.md)
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性,不支持[Menu控制](ts-universal-attributes-menu.md)
| 名称 | 参数类型 | 描述 |
| --------------------------- | ---------------------------------------- | ---------------------------------------- |
......@@ -42,29 +36,29 @@ Swiper(value:{controller?: SwiperController})
| loop | boolean | 是否开启循环。<br>设置为true时表示开启循环,在LazyForEach懒循环加载模式下,加载的组件数量建议大于5个。<br/>默认值:true |
| duration | number | 子组件切换的动画时长,单位为毫秒。<br/>默认值:400 |
| vertical | boolean | 是否为纵向滑动。<br/>默认值:false |
| itemSpace | Length | 设置子组件与子组件之间间隙。<br/>默认值:0 |
| itemSpace | number&nbsp;\|&nbsp;string | 设置子组件与子组件之间间隙。<br/>默认值:0 |
| displayMode | SwiperDisplayMode | 主轴方向上元素排列的模式,优先以displayCount设置的个数显示,displayCount未设置时本属性生效。<br/>默认值:SwiperDisplayMode.Stretch |
| cachedCount<sup>8+</sup> | number | 设置预加载子组件个数。<br/>默认值:1 |
| disableSwipe<sup>8+</sup> | boolean | 禁用组件滑动切换功能。<br/>默认值:false |
| curve<sup>8+</sup> | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过插值计算模块提供的接口创建自定义的Curves([插值曲线对象](ts-interpolation-calculation.md))。<br/>默认值:Curve.Ease |
| indicatorStyle<sup>8+</sup> | {<br/>left?:&nbsp;Length,<br/>top?:&nbsp;Length,<br/>right?:&nbsp;Length,<br/>bottom?:&nbsp;Length,<br/>size?:&nbsp;Length,<br/>mask?:&nbsp;boolean,<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md),<br/>selectedColor?:&nbsp;[ResourceColor](../../ui/ts-types.md)<br/>} | - | 设置indicator样式:<br/>-&nbsp;left:&nbsp;设置导航点距离Swiper组件左边的距离。<br/>-&nbsp;top:&nbsp;设置导航点距离Swiper组件顶部的距离。<br/>-&nbsp;right:&nbsp;设置导航点距离Swiper组件右边的距离。<br/>-&nbsp;bottom:&nbsp;设置导航点距离Swiper组件底部的距离。<br/>-&nbsp;size:&nbsp;设置导航点的直径。<br/>-&nbsp;mask:&nbsp;设置是否显示导航点蒙层样式。<br/>-&nbsp;color:&nbsp;设置导航点的颜色。<br/>-&nbsp;selectedColor:&nbsp;设置选中的导航点的颜色。 |
| indicatorStyle<sup>8+</sup> | {<br/>left?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>top?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>right?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>bottom?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>size?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>mask?:&nbsp;boolean,<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md),<br/>selectedColor?:&nbsp;[ResourceColor](../../ui/ts-types.md)<br/>} | 设置导航点样式:<br/>\- left: 设置导航点距离Swiper组件左边的距离。<br/>\- top: 设置导航点距离Swiper组件顶部的距离。<br/>\- right: 设置导航点距离Swiper组件右边的距离。<br/>\- bottom: 设置导航点距离Swiper组件底部的距离。<br/>\- size: 设置导航点的直径。<br/>\- mask: 设置是否显示导航点蒙层样式。<br/>\- color: 设置导航点的颜色。<br/>\- selectedColor: 设置选中的导航点的颜色。 |
| displayCount<sup>8+</sup> | number\|string | 设置元素显示个数。<br/>默认值:1 |
| effectMode<sup>8+</sup> | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。<br/>默认值:EdgeEffect.Spring |
## SwiperDisplayMode枚举说明
| 名称 | 描述 |
| ----------- | ------------------------------------------ |
| Stretch | Swiper滑动一页的宽度为Swiper组件自身的宽度。|
| AutoLinear | Swiper滑动一页的宽度为子组件宽度中的最大值。|
| 名称 | 描述 |
| ----------- | ------------------------------------------ |
| Stretch | Swiper滑动一页的宽度为Swiper组件自身的宽度。|
| AutoLinear | Swiper滑动一页的宽度为子组件宽度中的最大值。|
## EdgeEffect枚举说明
| 名称 | 描述 |
| ------ | ------------------------------------------------------------------------- |
| Spring | 弹性物理动效,滑动到边缘后可以通过触摸事件继续滑动一段距离,松手后回弹。 |
| Fade | 滑动到边缘后,可以通过触摸事件继续滑动一段阴影,松手后阴影回弹。 |
| None | 滑动到边缘后无效果。 |
| 名称 | 描述 |
| ------ | ------------------------------------------------------------------------- |
| Spring | 弹性物理动效,滑动到边缘后可以通过触摸事件继续滑动一段距离,松手后回弹。 |
| Fade | 滑动到边缘后,可以通过触摸事件继续滑动一段阴影,松手后阴影回弹。 |
| None | 滑动到边缘后无效果。 |
## SwiperController
......
......@@ -58,7 +58,8 @@ Line(options?: {width?: string | number, height?: string | number})
struct LineExample {
build() {
Column() {
Line({ width: 50, height: 100 }).startPoint([0, 0]).endPoint([50, 100])
Line().startPoint([0, 0]).endPoint([50, 100])
Line({ width: 50, height: 50 }).startPoint([0, 0]).endPoint([100, 100])
Line().width(200).height(200).startPoint([50, 50]).endPoint([150, 150])
}.margin({ top: 5 })
}
......
# Polygon
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
多边形绘制组件。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......
# Polyline
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
折线绘制组件。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......
# Rect
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
矩形绘制组件。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......
# Shape
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
绘制组件的父组件,父组件中会描述所有绘制组件均支持的通用属性。
1、绘制组件使用Shape作为父组件,实现类似SVG的效果。
2、绘制组件单独使用,用于在页面上绘制指定的图形。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......
......@@ -9,10 +9,10 @@
| 接口名称 | 功能描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| animateTo(value:&nbsp;[AnimationOptions](#animationoptions对象说明),&nbsp;event:&nbsp;()=&gt;&nbsp;void)&nbsp;:&nbsp;void | 提供全局animateTo显式动画接口来指定由于闭包代码导致的状态变化插入过渡动效。<br/>event指定显示动效的闭包函数,在闭包函数中导致的状态变化系统会自动插入过渡动画。 |
| animateTo(value:&nbsp;[AnimateParam](#animateparam对象说明),&nbsp;event:&nbsp;()=&gt;&nbsp;void)&nbsp;:&nbsp;void | 提供全局animateTo显式动画接口来指定由于闭包代码导致的状态变化插入过渡动效。<br/>event指定显示动效的闭包函数,在闭包函数中导致的状态变化系统会自动插入过渡动画。 |
## AnimationOptions对象说明
## AnimateParam对象说明
| 名称 | 类型 | 描述 |
| -------- | -------- | -------- |
......
# 页面间转场
页面转场通过在全局pageTransition方法内配置页面入场组件和页面退场组件来自定义页面转场动效。
在全局pageTransition方法内配置页面入场和页面退场时的自定义转场动效。
> **说明:**
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
| 名称 | 参数 | 参数描述 |
| ------------------- | ------ | ------------------------------- |
| PageTransitionEnter | Object | 页面入场组件,用于自定义当前页面的入场效果,详见动效参数说明。 |
| PageTransitionExit | Object | 页面退场组件,用于自定义当前页面的退场效果,详见动效参数说明。 |
| 名称 | 参数 | 参数描述 |
| ------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| PageTransitionEnter | {<br/>type: RouteType,<br/>duration: number,<br/>curve: Curve&nbsp;\|&nbsp;Curves,<br>delay: number<br/>} | 设置当前页面的自定义入场动效。<br/>-&nbsp;type:不配置时表明pop为push时效果的逆播。<br/>-&nbsp;duration:动画的时长,单位为毫秒。<br/>-&nbsp;curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md)&nbsp;<br/>&nbsp;默认值:Curve.Linear<br/>-&nbsp;delay:动画延迟时长,单位为毫秒,默认不延迟播放。 |
| PageTransitionExit | {<br/>type: RouteType,<br/>duration: number,<br/>curve: Curve&nbsp;\|&nbsp;Curves,<br/>delay: number<br/>} | 设置当前页面的自定义退场动效。<br/>-&nbsp;type:不配置时表明pop为push时效果的逆播<br/>-&nbsp;duration:动画的时长,单位为毫秒。<br/>-&nbsp;curve:动画曲线,有效值参见[Curve](ts-animatorproperty.md)&nbsp;<br/>&nbsp;默认值:Curve.Linear<br/>-&nbsp;delay:动画延迟时长,单位为毫秒,默认不延迟播放。 |
## RouteType枚举说明
- 动效参数说明
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| -------- | ------------------------- | ------ | ---- | ---------------------------------------- |
| type | RouteType | - | 否 | 不配置时表明pop为push时效果的逆播。 |
| duration | number | 1000 | 否 | 动画时长,单位为毫秒。 |
| curve | Curve&nbsp;\|&nbsp;Curves | Linear | 否 | 动画曲线,有效值参见[Curve](ts-animatorproperty.md)&nbsp;说明。 |
| delay | number | 0 | 否 | 动画延迟时长,单位为毫秒,默认不延时播放。 |
- RouteType枚举说明
| 名称 | 描述 |
| ---- | ---------------- |
| Pop | 重定向指定页面。PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。 |
| Push | 跳转到下一页面。PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。 |
| 名称 | 描述 |
| ---- | ------------------------------------------------------------ |
| Pop | 重定向指定页面。PageA跳转到PageB时,PageA为Exit+Push,PageB为Enter+Push。 |
| Push | 跳转到下一页面。PageB返回至PageA时,PageA为Enter+Pop,PageB为Exit+Pop。 |
| None | 页面未重定向。 |
## 属性
PageTransitionEnter和PageTransitionExit组件支持的属性:
| 参数名称 | 参数类型 | 必填 | 参数描述 |
| --------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| slide | SlideEffect | 否 | 设置页面转场时的滑入滑出效果。<br/>默认值:SlideEffect.Right |
| translate | {<br/>x?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>y?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>z?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置页面转场时的平移效果,为入场时起点和退场时终点的值,和slide同时设置时默认生效slide。<br/>-&nbsp;x:横向的平移距离。<br/>-&nbsp;y:纵向的平移距离。<br/>-&nbsp;z:竖向的平移距离。 |
| scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | 否 | 设置页面转场时的缩放效果,为入场时起点和退场时终点的值。<br/>-&nbsp;x:横向放大倍数(或缩小比例)。<br/>-&nbsp;y:纵向放大倍数(或缩小比例)。<br/>-&nbsp;z:竖向放大倍数(或缩小比例)。<br/>-&nbsp;centerX、centerY缩放中心点。<br/>-&nbsp;中心点为0时,默认的是组件的左上角。<br/> |
| opacity | number | 否 | 设置入场的起点透明度值或者退场的终点透明度值。<br/>默认值:1 |
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| --------- | ---------------------------------------- | ----------------- | ---- | ---------------------------------------- |
| slide | SlideEffect | SlideEffect.Right | 否 | 设置转场的滑入效果,有效值参见SlideEffect枚举说明。 |
| translate | {<br/>x?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>y?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>z?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | - | 否 | 设置页面转场时的平移效果,为入场时起点和退场时终点的值,和slide同时设置时默认生效slide。 |
| scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string,<br/>centerY?&nbsp;:&nbsp;number&nbsp;\|&nbsp;string<br/>} | - | 否 | 设置页面转场时的缩放效果,为入场时起点和退场时终点的值。 |
| opacity | number | 1 | 否 | 设置入场的起点透明度值或者退场的终点透明度值。 |
## SlideEffect枚举说明
- SlideEffect枚举说明
| 名称 | 描述 |
| ------ | ------------------------- |
| Left | 设置到入场时表示从左边滑入,出场时表示滑出到左边。 |
| Right | 设置到入场时表示从右边滑入,出场时表示滑出到右边。 |
| Top | 设置到入场时表示从上边滑入,出场时表示滑出到上边。 |
| Bottom | 设置到入场时表示从下边滑入,出场时表示滑出到下边。 |
| 名称 | 描述 |
| ------ | ------------------------- |
| Left | 设置到入场时表示从左边滑入,出场时表示滑出到左边。 |
| Right | 设置到入场时表示从右边滑入,出场时表示滑出到右边。 |
| Top | 设置到入场时表示从上边滑入,出场时表示滑出到上边。 |
| Bottom | 设置到入场时表示从下边滑入,出场时表示滑出到下边。 |
## 事件
PageTransitionEnter和PageTransitionExit组件支持的事件:
| 事件 | 功能描述 |
| ---------------------------------------- | ----------------------------------- |
| onEnter(type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void | 回调入参为当前入场动画的归一化进度[0&nbsp;-&nbsp;1]。 |
| onExit(type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void | 回调入参为当前退场动画的归一化进度[0&nbsp;-&nbsp;1]。 |
| 事件 | 功能描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| onEnter(event: (type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 回调入参为当前入场动画的归一化进度[0&nbsp;-&nbsp;1]。<br/>-&nbsp;type:跳转方法。<br/>-&nbsp;progress:当前进度。 |
| onExit(event: (type:&nbsp;RouteType,&nbsp;progress:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 回调入参为当前退场动画的归一化进度[0&nbsp;-&nbsp;1]。<br/>-&nbsp;type:跳转方法。<br/>-&nbsp;progress:当前进度。 |
## 示例
......
# 组件内转场
组件转场主要通过transition属性进行配置转场参数,在组件插入和删除时进行过渡动效,主要用于容器组件子组件插入删除时提升用户体验(需要配合animateTo才能生效,动效时长、曲线、延时跟随animateTo中的配置)。
组件内转场主要通过transition属性配置转场参数,在组件插入和删除时显示过渡动效,主要用于容器组件中的子组件插入和删除时,提升用户体验(需要配合[animateTo](ts-explicit-animation.md)才能生效,动效时长、曲线、延时跟随animateTo中的配置)。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
| 名称 | 参数类型 | 默认值 | 参数描述 |
| 名称 | 参数类型 | 参数描述 |
| -------- | -------- | -------- |
| transition | TransitionOptions | 所有参数均为可选参数,详细描述见TransitionOptions参数说明。 |
## TransitionOptions参数说明
| 参数名称 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| transition | Object | - | 所有参数均为可选参数,详细描述见transition入参说明。 |
- transition入参说明
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| type | [TransitionType](ts-appendix-enums.md#transitiontype) | TransitionType.All | 否 | 默认包括组件新增和删除。<br/>>&nbsp;&nbsp;**说明:**<br/>>&nbsp;不指定Type时说明插入删除使用同一种效果。 |
| opacity | number | 1 | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。 |
| translate | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number<br/>} | - | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。<br/>-x:横向的平移距离。<br/>-y:纵向的平移距离。<br/>-z:竖向的平移距离。 |
| scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number,<br/>centerY?&nbsp;:&nbsp;number<br/>} | - | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。<br/>-x:横向放大倍数(或缩小比例)。<br/>-y:纵向放大倍数(或缩小比例)。<br/>-z:竖向放大倍数(或缩小比例)。<br/>-&nbsp;centerX、centerY缩放中心点。<br/>-&nbsp;中心点为0时,默认的是组件的左上角。<br/> |
| rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;Angle,<br/>centerX?:&nbsp;Length,<br/>centerY?:&nbsp;Length<br/>} | - | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。<br/>-x:横向的旋转向量。<br/>-y:纵向的旋转向量。<br/>-z:竖向的旋转向量。<br/>-&nbsp;centerX,centerY指旋转中心点。<br/>-&nbsp;中心点为(0,0)时,默认的是组件的左上角。 |
| type | [TransitionType](ts-appendix-enums.md#transitiontype) | 否 | 默认包括组件新增和删除。<br/>默认值:TransitionType.All<br/>**说明:**<br/>不指定Type时说明插入删除使用同一种效果。 |
| opacity | number | 否 | 设置组件转场时的透明度效果,为插入时起点和删除时终点的值。<br/>默认值:1 |
| translate | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number<br/>} | 否 | 设置组件转场时的平移效果,为插入时起点和删除时终点的值。<br/>-x:横向的平移距离。<br/>-y:纵向的平移距离。<br/>-z:竖向的平移距离。 |
| scale | {<br/>x?&nbsp;:&nbsp;number,<br/>y?&nbsp;:&nbsp;number,<br/>z?&nbsp;:&nbsp;number,<br/>centerX?&nbsp;:&nbsp;number,<br/>centerY?&nbsp;:&nbsp;number<br/>} | 否 | 设置组件转场时的缩放效果,为插入时起点和删除时终点的值。<br/>-x:横向放大倍数(或缩小比例)。<br/>-y:纵向放大倍数(或缩小比例)。<br/>-z:竖向放大倍数(或缩小比例)。<br/>-&nbsp;centerX、centerY缩放中心点。<br/>-&nbsp;中心点为0时,默认的是组件的左上角。<br/> |
| rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;Angle,<br/>centerX?:&nbsp;Length,<br/>centerY?:&nbsp;Length<br/>} | 否 | 设置组件转场时的旋转效果,为插入时起点和删除时终点的值。<br/>-x:横向的旋转向量。<br/>-y:纵向的旋转向量。<br/>-z:竖向的旋转向量。<br/>-&nbsp;centerX,centerY指旋转中心点。<br/>-&nbsp;中心点为(0,0)时,默认的是组件的左上角。 |
## 示例
......
# 共享元素转场
共享元素转场支持页面间的转场,如当前页面的图片转场至下一页面中。
设置页面间转场时共享元素的转场动效。
> **说明:**
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
| 名称 | 参数 | 默认值 | 参数描述 |
| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| sharedTransition | id:&nbsp;string,<br/>options?:&nbsp;Object | - | 两个页面的组件配置为同一个id,则转场过程中会进行共享元素转场,配置为空字符串时不会有共享元素转场效果。 |
- options参数说明
| 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 |
| -------- | ------------------------- | ------ | ---- | --------------------- |
| duration | number | 1000 | 否 | 单位为毫秒,默认动画时长为1000毫秒。 |
| curve | Curve&nbsp;\|&nbsp;Curves | Linear | 否 | 默认曲线为线性,有效值参见Curve说明。 |
| delay | number | 0 | 否 | 单位为毫秒,默认不延时播放。 |
| 名称 | 参数 | 参数描述 |
| ---------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| sharedTransition | id:&nbsp;string,<br/>{<br/>duration?: number,<br/>curve?: Curve&nbsp;\|&nbsp;string,<br/>delay?: number,<br/>motionPath?: <br/>{<br/>path: string,<br/>form?: number,<br/>to?: number,<br/>rotatable?: boolean<br/>},<br/>zIndex?: number,<br/>type?: [SharedTransitionEffectType](ts-appendix-enums.md#sharedtransitioneffecttype)<br/>} | 两个页面中id值相同且不为空字符串的组件即为共享元素,在页面转场时可显示共享元素转场动效。<br/>-&nbsp; id:设置组件的id。<br/>-&nbsp; duration:单位为毫秒,默认动画时长为1000毫秒。<br/>-&nbsp;curve:默认曲线为Linear,有效值参见[Curve](ts-animatorproperty.md)&nbsp;说明。<br/>-&nbsp;delay:单位为毫秒,默认不延时播放。<br/>-&nbsp;motionPath:运动路径信息。<br/>-&nbsp;path:设置路径。<br/>-&nbsp;from:设置起始值。<br/>-&nbsp;to:设置终止值。<br/>-&nbsp;rotatable:是否旋转。<br/>-&nbsp;zIndex:设置Z轴。<br/>-&nbsp;type:动画类型。 |
## 示例
示例功能为两个页面,共享元素转场页面图片点击后转场至页面B的图片。
示例代码为点击图片跳转页面时,显示共享元素图片的自定义转场动效。
```ts
// xxx.ets
......
# 背景设置
设置组件的背景
设置组件的背景样式
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| backgroundColor | [ResourceColor](../../ui/ts-types.md) | - | 设置组件的背景色。 |
| backgroundImage | src:&nbsp;[ResourceStr](../../ui/ts-types.md),<br/>repeat?:&nbsp;[ImageRepeat](ts-appendix-enums.md#imagerepeat) | - | src参数:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。<br/>repeat参数:设置背景图片的重复样式,默认不重复。 |
| backgroundImageSize | {<br/>width?:&nbsp;Length,<br/>height?:&nbsp;Length<br/>}&nbsp;\|&nbsp;[ImageSize](ts-appendix-enums.md#imagesize) | Auto | 设置背景图像的高度和宽度。当输入为{width:&nbsp;Length,&nbsp;height:&nbsp;Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。 |
| backgroundImagePosition | {<br/>x?:&nbsp;Length,<br/>y?:&nbsp;Length<br/>}&nbsp;\|&nbsp;[Alignment](ts-appendix-enums.md#alignment) | {<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} | 设置背景图在组件中显示位置。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| backgroundColor | [ResourceColor](../../ui/ts-types.md) | 设置组件的背景色。 |
| backgroundImage | -&nbsp;src:&nbsp;[ResourceStr](../../ui/ts-types.md),<br/>-&nbsp;repeat?:&nbsp;[ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。<br/>repeat:设置背景图片的重复样式,默认不重复。 |
| backgroundImageSize | {<br/>width?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>height?:&nbsp;[Length](../../ui/ts-types.md#length)<br/>}&nbsp;\|&nbsp;[ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width:&nbsp;Length,&nbsp;height:&nbsp;Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。<br/>默认值:ImageSize.Auto |
| backgroundImagePosition | {<br/>x?:&nbsp;[Length](../../ui/ts-types.md#length),<br/>y?:&nbsp;[Length](../../ui/ts-types.md#length)<br/>}&nbsp;\|&nbsp;[Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。<br/>默认值:<br/>{<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} |
## 示例
......
......@@ -3,12 +3,8 @@
设置组件是否可以响应点击事件、触摸事件等手指交互事件。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
......
......@@ -3,23 +3,18 @@
> **说明:**
> - 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> - 仅当父组件是Flex组件时生效。
## 权限列表
> - 仅当父组件是 Flex、Column、Row 时生效。
## 属性
| 名称 | 参数说明 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| flexBasis | 'auto'&nbsp;\|&nbsp;Length | 'auto' | 此属性所在的组件在Flex容器中主轴方向上基准尺寸。 |
| flexGrow | number | 0 | Flex容器的剩余空间分配给此属性所在组件的比例。 |
| flexShrink | number | 1 | Flex容器压缩尺寸分配给此属性所在组件的比例。 |
| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign枚举说明) | Auto | 覆盖Flex布局容器中alignItems默认配置。 |
| 名称 | 参数说明 | 描述 |
| -------- | -------- | -------- |
| flexBasis | number \| string | 设置组件在父容器主轴方向上的基准尺寸。<br/>默认值:'auto'(表示组件在主轴方向上的基准尺寸为组件原本的大小) |
| flexGrow | number | 设置父容器的剩余空间分配给此属性所在组件的比例。<br/>默认值:0 |
| flexShrink | number | 设置父容器压缩尺寸分配给此属性所在组件的比例。<br/>默认值:1 |
| alignSelf | [ItemAlign](ts-appendix-enums.md#itemalign) | 子组件在父容器交叉轴的对齐格式,覆盖Flex布局容器中alignItems默认配置。<br/>默认值:ItemAlign.Auto |
## 示例
......@@ -34,7 +29,7 @@ struct FlexExample {
Column({ space: 5 }) {
Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%')
// 基于主轴基准尺寸
// flexBasis()值可以是'auto'(默认值)元素本来的大小 ,如果是数字则类似于.width()/.height() ,基于主轴
// flexBasis()值可以是'auto',表示基准尺寸是元素本来的大小 ,也可以是长度设置,相当于.width()/.height()
Flex() {
Text('flexBasis(100)')
.flexBasis('100').height(100).lineHeight(70)
......
......@@ -76,3 +76,5 @@ struct ImageEffectsExample {
}
}
```
<img src="figures/image-effect.png" alt="image-effect" />
\ No newline at end of file
......@@ -3,24 +3,21 @@
设置组件的对齐方式、布局方向和显示位置。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| align | [Alignment](ts-appendix-enums.md#alignment) | Center | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。 |
| direction | [Direction](ts-appendix-enums.md#direction) | Auto | 设置元素水平方向的布局,可选值参照Direction枚举说明。 |
| position | {<br/>x:&nbsp;Length,<br/>y:&nbsp;Length<br/>} | - | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 |
| markAnchor | {<br/>x:&nbsp;Length,<br/>y:&nbsp;Length<br/>} | {<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。 |
| offset | {<br/>x:&nbsp;Length,<br/>y:&nbsp;Length<br/>} | {<br/>x:&nbsp;0,<br/>y:&nbsp;0<br/>} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。<br/>默认值:Alignment.Center |
| direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。<br/>默认值:Direction.Auto |
| position | {<br/>x:&nbsp;[Length](../../ui/ts-types.md#length),<br/>y:&nbsp;[Length](../../ui/ts-types.md#length)<br/>} | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 |
| markAnchor | {<br/>x:&nbsp;[Length](../../ui/ts-types.md#length),<br/>y:&nbsp;[Length](../../ui/ts-types.md#length)<br/>} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。<br/>默认值:<br/>{<br/>x: 0,<br/>y: 1<br/>} |
| offset | {<br/>x:&nbsp;[Length](../../ui/ts-types.md#length),<br/>y:&nbsp;[Length](../../ui/ts-types.md#length)<br/>} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。<br/>默认值:<br/>{<br/>x: 0,<br/>y: 1<br/>} |
| alignRules<sup>9+</sup> | {<br/>left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };<br/>bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };<br/>center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }<br/>} | 指定相对容器的对齐规则。<br/>-&nbsp;left:设置左对齐参数。<br/>-&nbsp;right:设置右对齐参数。<br/>-&nbsp;middle:设置中间对齐的参数。<br/>-&nbsp;top:设置顶部对齐的参数。<br/>-&nbsp;bottom:设置底部对齐的参数。<br/>-&nbsp;center:设置中心对齐的参数。<br/>**说明:**<br/>-&nbsp;anchor:设置作为锚点的组件的id值。<br>-&nbsp;align:设置相对于锚点组件的对齐方式。 |
## 示例
......
......@@ -3,28 +3,24 @@
为组件绑定弹出式菜单,弹出式菜单以垂直列表形式显示菜单项,可通过长按、点击或鼠标右键触发。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| ---------------------------- | ---------------------------------------- | ---- | ---------------------------------- |
| bindMenu | Array<MenuItem&gt;&nbsp;\|&nbsp;[CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 |
| bindContextMenu<sup>8+</sup> | content:&nbsp;[CustomBuilder](../../ui/ts-types.md),<br>responseType:&nbsp;[ResponseType](ts-appendix-enums.md#responsetype8) | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 |
| 名称 | 参数类型 | 描述 |
| ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| bindMenu | Array<MenuItem&gt;&nbsp;\|&nbsp;[CustomBuilder](../../ui/ts-types.md) | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 |
| bindContextMenu<sup>8+</sup> | content:&nbsp;[CustomBuilder](../../ui/ts-types.md),<br>responseType:&nbsp;[ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 |
## MenuItem
- MenuItem
| 名称 | 类型 | 描述 |
| ------ | ----------------------- | ----------- |
| value | string | 菜单项文本。 |
| action | ()&nbsp;=&gt;&nbsp;void | 点击菜单项的事件回调。 |
| 名称 | 类型 | 描述 |
| ------ | ----------------------- | ----------- |
| value | string | 菜单项文本。 |
| action | ()&nbsp;=&gt;&nbsp;void | 点击菜单项的事件回调。 |
## 示例
......
# 多态样式
> **说明:**
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
设置组件不同状态下的样式。
> **说明:**
>
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
## 属性
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| stateStyles | StateStyles | 设置组件不同状态的样式。 |
## 属性
## StateStyles接口说明
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| stateStyles | StateStyles | - | 设置组件不同状态的样式。 |
- StateStyles接口说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| normal | ()=&gt;void | 否 | - | 组件无状态时的样式。 |
| pressed | ()=&gt;void | 否 | - | 组件按下状态的样式。 |
| disabled | ()=&gt;void | 否 | - | 组件禁用状态的样式。 |
| focused | ()=&gt;void | 否 | - | 组件聚焦状态的样式。 |
| clicked | ()=&gt;void | 否 | - | 组件点击状态的样式。 |
| normal | ()=&gt;void | 否 | 组件无状态时的样式。 |
| pressed | ()=&gt;void | 否 | 组件按下状态的样式。 |
| disabled | ()=&gt;void | 否 | 组件禁用状态的样式。 |
| focused | ()=&gt;void | 否 | 组件获焦状态的样式。 |
| clicked | ()=&gt;void | 否 | 组件点击状态的样式。 |
## 示例
......
......@@ -3,43 +3,40 @@
设置组件点击时弹出的气泡框状态。
> **说明:**
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
## 接口
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| bindPopup | show:&nbsp;boolean,<br/>popup:&nbsp;PopupOptions&nbsp;\|&nbsp;CustomPopupOptions<sup>8+</sup> | 给组件绑定Popup,点击弹出弹窗。<br/>show:&nbsp;创建页面弹窗提示是否默认显示,默认值为false。<br/>popup:&nbsp;配置当前弹窗提示的参数。 |
## 属性
## PopupOptions类型说明
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| message | string | 是 | 弹窗信息内容。 |
| placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 |
| arrowOffset<sup>9+</sup> | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 |
| secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 |
| onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
## CustomPopupOptions<sup>8+</sup>类型说明
| 名称 | 参数类型 | 默认值 | 描述 |
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| bindPopup | show:&nbsp;boolean,<br/>popup:&nbsp;PopupOptions&nbsp;\|&nbsp;CustomPopupOptions | - | 给组件绑定Popup,点击弹出弹窗。<br/>show:&nbsp;创建页面弹窗提示是否默认显示,默认值为false。<br/>popup:&nbsp;配置当前弹窗提示的参数。 |
- PopupOptions类型接口说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| message | string | 是 | - | 弹窗信息内容。 |
| placementOnTop | boolean | 否 | false | 是否在组件上方显示,默认值为false。 |
| arrowOffset<sup>9+</sup> | Length | 否 | - | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧,默认居上。 |
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 |
| secondaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | - | 第二个按钮。<br/>value:&nbsp;弹窗里辅助按钮的文本。<br/>action:&nbsp;点击辅助按钮的回调函数。 |
| onStateChange | (isVisible:&nbsp;boolean)&nbsp;=&gt;&nbsp;void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
- CustomPopupOptions<sup>8+</sup>类型接口说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| builder | ()&nbsp;=&gt;&nbsp;any | 是 | - | 提示气泡内容的构造器。 |
| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | Placement.Bottom | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。 |
| arrowOffset<sup>9+</sup> | Length | 否 | - | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧,默认居上。 |
| maskColor | [ResourceColor](../../ui/ts-types.md) | 否 | - | 提示气泡遮障层的颜色。 |
| popupColor | [ResourceColor](../../ui/ts-types.md) | 否 | - | 提示气泡的颜色。 |
| enableArrow | boolean | 否 | true | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。 |
| autoCancel | boolean | 否 | true | 页面有操作时,是否自动关闭气泡 |
| onStateChange | (isVisible:&nbsp;boolean)&nbsp;=&gt;&nbsp;void | 否 | - | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 |
| builder | [CustomBuilder](../../ui/ts-types.md) | 是 | 提示气泡内容的构造器。 |
| placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。<br/>默认值:Placement.Bottom |
| arrowOffset<sup>9+</sup> | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| maskColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡遮障层的颜色。 |
| popupColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡的颜色。 |
| enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。<br/>默认值:true |
| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡<br/>默认值:true |
| onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 |
## 示例
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册