提交 2ae61809 编写于 作者: S sienna1128 提交者: Gitee

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

Signed-off-by: Nsienna1128 <lixiaoyan45@huawei.com>
......@@ -89,7 +89,7 @@ Register four synchronous APIs (`getSync`, `setSync`, `removeSync`, and`clearSyn
/***********************************************
* Module export and register
***********************************************/
static napi_value StorgeExport(napi_env env, napi_value exports)
static napi_value StorageExport(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
DECLARE_NAPI_FUNCTION("get", JSStorageGet),
......@@ -110,7 +110,7 @@ static napi_value StorgeExport(napi_env env, napi_value exports)
static napi_module storage_module = {.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = StorgeExport,
.nm_register_func = StorageExport,
.nm_modname = "storage",
.nm_priv = ((void*)0),
.reserved = {0}};
......
此差异已折叠。
# Motion Recognition
# Motion
## Overview
......@@ -8,7 +8,7 @@ The motion recognition module provides motion recognition and control capabiliti
The motion recognition driver is developed based on the hardware driver foundation (HDF). It shields hardware differences and provides APIs for the Multimodal Sensor Data Platform (MSDP) to implement capabilities such as enabling or disabling motion recognition, and subscribing to or unsubscribing from motion recognition data.
The figure below shows the motion recognition driver architecture. The framework layer provides MSDP services, and interacts with the Motion Hardware Device Interface (HDI) Server through the Motion HDI Client. The Motion HDI Server calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services.
The figure below shows the motion recognition driver architecture. The framework layer provides MSDP services, and interacts with the Motion Stub through the Motion Proxy in the User Hardware Driver Foundation (UHDF). The Motion Stub calls the Motion HDI Impl APIs to provide motion recognition capabilities for upper-layer services.
**Figure 1** Motion recognition driver architecture
......@@ -22,7 +22,7 @@ The figure below illustrates how a motion recognition driver works.
![](figures/motion_recognition_driver_work.png)
1. MSDP: The MSDP service obtains a Motion HDI service instance from the Motion Proxy at the IDL and calls the Motion HDI API.
1. MSDP: The MSDP service obtains a Motion HDI service instance from the Motion Proxy and calls the Motion HDI API.
2. IDL: The IService Manager allocates a Motion HDI instance requested by the MSDP service, and the Motion Proxy forwards the instance to the MSDP service. After the MSDP service calls the HDI API provided by the Motion Proxy, Motion Stub is called through Inter-Process Communication (IPC) to invoke the Motion Service API. The code is automatically generated by a tool and does not need to be developed by the component vendor.
3. HDI Service: HDI Service consists of Motion Interface Driver, Motion Service, and Motion Impl. Motion Interface Driver provides the motion recognition driver code. A **HdfDriverEntry** structure is defined to implement the **Init**, **Bind**, and **Release** functions. The **HDF_INIT** macro is used to load the driver in the functions. Motion Service provides the motion recognition service interface class. The specific implementation is described in Motion Impl. The code of HDI Service must be developed by the component vendor.
......
......@@ -55,15 +55,15 @@
| ----------- | ----------------------- | ------------------------------------------- |
| Preferences | flush(): Promise\<void> | 将Preferences实例通过异步线程回写入文件中。 |
### 订阅数据变
### 订阅数据变
订阅数据变更者类,订阅的Key的值发生变更后,在执行flush方法后,会触发callback回调。
订阅数据变更,订阅的Key的值发生变更后,在执行flush方法后,会触发callback回调。
**表5** 首选项变化订阅接口
| 类名 | 接口名 | 描述 |
| ----------- | ------------------------------------------------------------ | -------------- |
| Preferences | on(type: 'change', callback: Callback<{ key : string }>): void | 订阅数据变。 |
| Preferences | on(type: 'change', callback: Callback<{ key : string }>): void | 订阅数据变。 |
| Preferences | off(type: 'change', callback: Callback<{ key : string }>): void | 注销订阅。 |
### 删除数据文件
......@@ -88,8 +88,30 @@
2. 获取Preferences实例。
读取指定文件,将数据加载到Preferences实例,用于数据操作。
FA模型示例:
```js
let promise = data_preferences.getPreferences(this.context, 'mystore');
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
let promise = data_preferences.getPreferences(context, 'mystore');
```
Stage模型示例:
```ts
// 获取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. 存入数据。
......@@ -134,9 +156,9 @@
preferences.flush();
```
6. 订阅数据变
6. 订阅数据变
应用订阅数据变需要指定observer作为回调方法。订阅的Key的值发生变更后,当执行flush方法时,observer被触发回调。
应用订阅数据变需要指定observer作为回调方法。订阅的Key的值发生变更后,当执行flush方法时,observer被触发回调。
```js
var observer = function (key) {
......
......@@ -12,7 +12,7 @@ HiTraceMeter为开发者提供系统性能打点接口。开发者通过在自
| 接口名 | 返回值 | 描述 |
| ---------------------------------------------------------------------------- | --------- | ------------ |
| hiTraceMeter.startTrace(name: string, taskId: number, expectedTime?: number) | void | 标记一个预跟踪耗时任务的开始。如果有多个相同name的任务需要跟踪或者对同一个任务要跟踪多次,并且任务同时被执行,则每次调用startTrace的taskId不相同。如果具有相同name的任务是串行执行的,则taskId可以相同。 |
| hiTraceMeter.startTrace(name: string, taskId: number) | void | 标记一个预跟踪耗时任务的开始。如果有多个相同name的任务需要跟踪或者对同一个任务要跟踪多次,并且任务同时被执行,则每次调用startTrace的taskId不相同。如果具有相同name的任务是串行执行的,则taskId可以相同。 |
| hiTraceMeter.finishTrace(name: string, taskId: number) | void | name和taskId必须与流程开始的hiTraceMeter.startTrace对应参数值保持一致。 |
| hiTraceMeter.traceByValue(name: string, value: number) | void | 用来标记一个预跟踪的数值变量,该变量的数值会不断变化。|
......@@ -32,10 +32,6 @@ HiTraceMeter为开发者提供系统性能打点接口。开发者通过在自
onInit() {
this.title = this.$t('strings.world');
// 从startTrace到finishTrace流程的耗时期望为5ms
hiTraceMeter.startTrace("business", 1);
hiTraceMeter.startTrace("business", 1, 5);
// 跟踪并行执行的同名任务
hiTraceMeter.startTrace("business", 1);
// 业务流程
......
# 数据管理开发常见问题
## 如何将PixelMap的数据存储到数据库中。
适用于:OpenHarmony SDK 3.2.3.5版本
PixelMap应该被转换成相应的ArrayBuffer再放进数据库。
参考文档:[readPixelsToBuffer](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-image.md#readpixelstobuffer7-1)
参考文档:[readPixelsToBuffer](../reference/apis/js-apis-image.md#readpixelstobuffer7-1)
## 如何获取rdb关系型数据库文件
......@@ -18,7 +16,6 @@ PixelMap应该被转换成相应的ArrayBuffer再放进数据库。
示例:
```
```shell
hdc_std file recv /data/app/el2/100/database/com.xxxx.xxxx/entry/db/test.db ./test.db
```
......@@ -52,7 +52,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) //获取相机ID
console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) //获取相机位置
console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) //获取相机类型
......
......@@ -90,7 +90,7 @@ export default storage;
/***********************************************
* Module export and register
***********************************************/
static napi_value StorgeExport(napi_env env, napi_value exports)
static napi_value StorageExport(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
DECLARE_NAPI_FUNCTION("get", JSStorageGet),
......@@ -111,7 +111,7 @@ static napi_value StorgeExport(napi_env env, napi_value exports)
static napi_module storage_module = {.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = StorgeExport,
.nm_register_func = StorageExport,
.nm_modname = "storage",
.nm_priv = ((void*)0),
.reserved = {0}};
......
......@@ -3953,7 +3953,7 @@ var audioStreamInfo = {
var audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 0
}
......@@ -3973,7 +3973,7 @@ audioRenderer.getBufferSize().then((data)=> {
console.info(`AudioFrameworkRenderLog: getBufferSize: SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.error.(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
});
console.info(`Buffer size: ${bufferSize}`);
var context = featureAbility.getContext();
......
......@@ -174,6 +174,7 @@ CommonEvent模块支持的事件类型。名称指的是系统公共事件宏;
| COMMON_EVENT_SPLIT_SCREEN<sup>8+<sup> | usual.event.SPLIT_SCREEN | ohos.permission.RECEIVER_SPLIT_SCREEN | 表示分屏的公共事件的动作。 |
| COMMON_EVENT_SLOT_CHANGE<sup>9+<sup> | usual.event.SLOT_CHANGE | ohos.permission.NOTIFICATION_CONTROLLER | 表示通知通道更新的动作。 |
| COMMON_EVENT_SPN_INFO_CHANGED <sup>9+<sup> | usual.event.SPN_INFO_CHANGED | 无 | 表示spn显示信息已更新的公共事件的动作。 |
| COMMON_EVENT_QUICK_FIX_APPLY_RESULT <sup>9+<sup> | usual.event.QUICK_FIX_APPLY_RESULT | 无 | 指示快速修复应用的动作。 |
## CommonEvent.publish
......
......@@ -38,15 +38,21 @@ getPreferences(context: Context, name: string, callback: AsyncCallback&lt;Prefer
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
| callback | AsyncCallback&lt;[Preferences](#preferences)&gt; | 是 | 回调函数。当获取Preferences实例成功,err为undefined,返回Preferences实例;否则err为错误码。 |
**示例:**
FA模型示例:
```js
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
var preferences = null;
data_preferences.getPreferences(this.context, 'mystore', function (err, object) {
data_preferences.getPreferences(context, 'mystore', function (err, object) {
if (err) {
console.info("Failed to get preferences. Cause: " + err);
return;
......@@ -56,6 +62,28 @@ data_preferences.getPreferences(this.context, 'mystore', function (err, object)
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context;
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
var preferences = null;
data_preferences.getPreferences(context, 'mystore', function (err, object) {
if (err) {
console.info("Failed to get preferences. Cause: " + err);
return;
}
preferences = object;
console.info("Succeeded in getting preferences.");
})
```
## data_preferences.getPreferences
......@@ -69,7 +97,7 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------- | ---- | ----------------------- |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
**返回值:**
......@@ -80,9 +108,15 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt;
**示例:**
FA模型示例:
```js
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
var preferences = null;
let promise = data_preferences.getPreferences(this.context, 'mystore')
let promise = data_preferences.getPreferences(context, 'mystore')
promise.then((object) => {
preferences = object;
console.info("Succeeded in getting preferences.");
......@@ -91,6 +125,27 @@ promise.then((object) => {
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context;
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
var preferences = null;
let promise = data_preferences.getPreferences(context, 'mystore')
promise.then((object) => {
preferences = object;
console.info("Succeeded in getting preferences.");
}).catch((err) => {
console.info("Failed to get preferences. Cause: " + err);
})
```
## data_preferences.deletePreferences
......@@ -108,14 +163,20 @@ deletePreferences(context: Context, name: string, callback: AsyncCallback&lt;voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ---------------------------------------------------- |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当移除成功,err为undefined,否则为错误码。 |
**示例:**
FA模型示例:
```js
data_preferences.deletePreferences(this.context, 'mystore', function (err) {
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete preferences. Cause: " + err);
return
......@@ -124,6 +185,26 @@ data_preferences.deletePreferences(this.context, 'mystore', function (err) {
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
data_preferences.deletePreferences(context, 'mystore', function (err) {
if (err) {
console.info("Failed to delete preferences. Cause: " + err);
return
}
console.info("Succeeded in deleting preferences." );
})
```
## data_preferences.deletePreferences
......@@ -141,7 +222,7 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------- | ---- | ----------------------- |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
**返回值:**
......@@ -152,8 +233,14 @@ deletePreferences(context: Context, name: string): Promise&lt;void&gt;
**示例:**
FA模型示例:
```js
let promise = data_preferences.deletePreferences(this.context, 'mystore')
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
let promise = data_preferences.deletePreferences(context, 'mystore')
promise.then(() => {
console.info("Succeeded in deleting preferences.");
}).catch((err) => {
......@@ -161,6 +248,25 @@ promise.then(() => {
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
let promise = data_preferences.deletePreferences(context, 'mystore')
promise.then(() => {
console.info("Succeeded in deleting preferences.");
}).catch((err) => {
console.info("Failed to delete preferences. Cause: " + err);
})
```
## data_preferences.removePreferencesFromCache
......@@ -176,14 +282,20 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------- | ---- | ---------------------------------------------------- |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当移除成功,err为undefined,否则为错误码。 |
**示例:**
FA模型示例:
```js
data_preferences.removePreferencesFromCache(this.context, 'mystore', function (err) {
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove preferences. Cause: " + err);
return;
......@@ -192,6 +304,26 @@ data_preferences.removePreferencesFromCache(this.context, 'mystore', function (e
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
data_preferences.removePreferencesFromCache(context, 'mystore', function (err) {
if (err) {
console.info("Failed to remove preferences. Cause: " + err);
return;
}
console.info("Succeeded in removing preferences.");
})
```
## data_preferences.removePreferencesFromCache
......@@ -207,7 +339,7 @@ removePreferencesFromCache(context: Context, name: string): Promise&lt;void&gt;
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------- | ---- | ----------------------- |
| context | [Context](js-apis-ability-context.md) | 是 | 应用上下文。 |
| context | Context | 是 | 应用上下文。<br>FA模型的应用Context定义见[Context](js-apis-Context.md)<br>Stage模型的应用Context定义见[Context](js-apis-ability-context.md)。 |
| name | string | 是 | Preferences实例的名称。 |
**返回值:**
......@@ -218,8 +350,14 @@ removePreferencesFromCache(context: Context, name: string): Promise&lt;void&gt;
**示例:**
FA模型示例:
```js
let promise = data_preferences.removePreferencesFromCache(this.context, 'mystore')
// 获取context
import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext()
let promise = data_preferences.removePreferencesFromCache(context, 'mystore')
promise.then(() => {
console.info("Succeeded in removing preferences.");
}).catch((err) => {
......@@ -227,6 +365,25 @@ promise.then(() => {
})
```
Stage模型示例:
```ts
// 获取context
import Ability from '@ohos.application.Ability'
var context
class MainAbility extends Ability{
onWindowStageCreate(windowStage){
context = this.context
}
}
let promise = data_preferences.removePreferencesFromCache(context, 'mystore')
promise.then(() => {
console.info("Succeeded in removing preferences.");
}).catch((err) => {
console.info("Failed to remove preferences. Cause: " + err);
})
```
## Preferences
......
......@@ -134,7 +134,7 @@ onVisibilityChange(newStatus: { [key: string]: number }): void
**示例:**
```js
import formBindingData from '@ohos.application.formBindingData'
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onVisibilityChange(newStatus) {
console.log('FormExtension onVisibilityChange, newStatus:' + newStatus);
......
......@@ -32,7 +32,7 @@ import hiAppEvent from '@ohos.hiAppEvent';
事件参数为object类型,key为事件的参数名称,value为事件的参数值,其规格定义如下:
- 参数名为string类型,字符串非空且长度在16个字符以内,有效的字符是0-9、a-z、下划线,不能以下划线开头或结尾
- 参数名为string类型,字符串非空且长度在16个字符以内,有效的字符是0-9、a-z、下划线,不能以下划线开头或结尾
- 参数值支持string、number、boolean、Array类型;
- 参数值为string类型时,其长度需在8*1024个字符以内,超出会做截断处理;
- 参数值为Array类型时,Array中的元素类型只能全为string、number、boolean中的一种,且元素个数需在100以内,超出会做丢弃处理;
......@@ -304,11 +304,8 @@ hiAppEvent.addWatcher({
console.error("holder is null");
return;
}
while (true) {
let eventPkg = holder.takeNext();
if (eventPkg == null) {
return;
}
let eventPkg = null;
while ((eventPkg = holder.takeNext()) != null) {
console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row);
console.info("eventPkg.size=" + eventPkg.size);
......@@ -324,15 +321,14 @@ let holder = hiAppEvent.addWatcher({
name: "watcher2",
});
if (holder != null) {
let eventPkg = holder.takeNext();
if (eventPkg == null) {
return;
}
console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row);
console.info("eventPkg.size=" + eventPkg.size);
for (const eventInfo of eventPkg.data) {
console.info("eventPkg.data=" + eventInfo);
let eventPkg = null;
while ((eventPkg = holder.takeNext()) != null) {
console.info("eventPkg.packageId=" + eventPkg.packageId);
console.info("eventPkg.row=" + eventPkg.row);
console.info("eventPkg.size=" + eventPkg.size);
for (const eventInfo of eventPkg.data) {
console.info("eventPkg.data=" + eventInfo);
}
}
}
```
......@@ -417,6 +413,9 @@ setSize(size: number): void
**示例:**
```js
let holder = hiAppEvent.addWatcher({
name: "watcher",
});
holder.setSize(1000);
```
......@@ -429,6 +428,9 @@ takeNext(): [AppEventPackage](#appeventpackage9)
**示例:**
```js
let holder = hiAppEvent.addWatcher({
name: "watcher",
});
let eventPkg = holder.takeNext();
```
......
......@@ -71,7 +71,7 @@ import hiTraceChain from '@ohos.hiTraceChain';
## hiTraceChain.begin
begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId
begin(name: string, flags?: number): HiTraceId
开始跟踪,同步接口。
......@@ -82,7 +82,7 @@ begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| name | string | 是 | 跟踪业务名。 |
| flags | number | | 跟踪标志组合,具体可参考[HiTraceFlag](#hitraceflag)。 |
| flags | number | | 跟踪标志组合,具体可参考[HiTraceFlag](#hitraceflag)。 |
**返回值:**
......@@ -113,7 +113,7 @@ end(id: HiTraceId): void
**示例:**
```js
let asyncTraceId = hiTraceChain.begin("business");
let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,结束跟踪。
hiTraceChain.end(asyncTraceId);
```
......@@ -135,7 +135,7 @@ getId(): HiTraceId
**示例:**
```js
let traceId = hiTraceChain.begin("business");
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,获取当前HiTraceId。
let curTraceId = hiTraceChain.getId();
```
......@@ -158,7 +158,7 @@ setId(id: HiTraceId): void
```js
let asyncTraceId;
let traceId = hiTraceChain.begin("business");
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,设置当前HiTraceId。
hiTraceChain.setId(asyncTraceId);
```
......@@ -174,7 +174,7 @@ clearId(): void
**示例:**
```js
let traceId = hiTraceChain.begin("business");
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,清除当前HiTraceId。
hiTraceChain.clearId();
```
......@@ -196,7 +196,7 @@ createSpan(): HiTraceId
**示例:**
```js
let traceId = hiTraceChain.begin("business");
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
// 若干业务逻辑完成后,创建跟踪分支。
let spanTraceId = hiTraceChain.createSpan();
```
......@@ -249,7 +249,7 @@ isValid(id: HiTraceId): boolean
**示例:**
```js
let traceId = hiTraceChain.begin("business");
let traceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.DEFAULT);
let traceIdIsvalid = hiTraceChain.isValid(traceId);
```
......
......@@ -591,7 +591,7 @@ audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调
on(type: 'timeUpdate', callback: Callback\<number>): void
开始订阅音频播放[seek()](#seek)时间更新事件。
开始订阅音频播放时间更新事件。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer
......@@ -599,20 +599,20 @@ on(type: 'timeUpdate', callback: Callback\<number>): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 播放事件回调类型,支持的事件包括:'timeUpdate'。<br>- 'timeUpdate':[seek()](#audioplayer_seek)调用完成,触发该事件。 |
| callback | Callback\<number> | 是 | 播放事件回调方法。回调方法入参为成功seek的时间。 |
| type | string | 是 | 播放事件回调类型,支持的事件包括:'timeUpdate'。<br>- 'timeUpdate':音频播放时间戳更新,开始播放后自动触发该事件。 |
| callback | Callback\<number> | 是 | 播放事件回调方法。回调方法入参为更新后的时间戳。 |
**示例:**
```js
audioPlayer.on('timeUpdate', (seekDoneTime) => { //设置'timeUpdate'事件回调
if (seekDoneTime == null) {
console.info('audio seek fail');
audioPlayer.on('timeUpdate', (newTime) => { //设置'timeUpdate'事件回调
if (newTime == null) {
console.info('audio timeUpadate fail');
return;
}
console.log('audio seek success. seekDoneTime: ' + seekDoneTime);
console.log('audio timeUpadate success. seekDoneTime: ' + newTime);
});
audioPlayer.seek(30000); //seek到30000ms的位置
audioPlayer.play(); //开始播放后,自动触发时间戳更新事件
```
### on('error')
......
......@@ -8,6 +8,7 @@
>
> - 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口仅可在Stage模型下使用。
> - 延迟任务调度约束见[延迟任务调度概述](../../task-management/work-scheduler-overview.md)。
## 导入模块
......
# Slider
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
滑动条组件,用来快速调节设置值,如音量、亮度等。
## 权限列表
> **说明:**
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -19,38 +14,40 @@
## 接口
Slider(options:{value?: number, min?: number, max?: number, step?: number, style?: SliderStyle, direction?: Axis, reverse?: boolean})
Slider(options?: {value?: number, min?: number, max?: number, step?: number, style?: SliderStyle, direction?: Axis, reverse?: boolean})
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| value | number | 否 | 0 | 当前进度值。 |
| min | number | 否 | 0 | 设置最小值。 |
| max | number | 否 | 100 | 设置最大值。 |
| step | number | 否 | 1 | 设置Slider滑动跳动值,当设置相应的step时,Slider为间歇滑动。 |
| style | SliderStyle | 否 | SliderStyle.OutSet | 设置Slider的滑块样式。 |
| direction<sup>8+</sup> | [Axis](ts-appendix-enums.md#axis) | 否 | Axis.Horizontal | 设置滑动条滑动方向为水平或竖直方向。 |
| reverse<sup>8+</sup> | boolean | 否 | false | 设置滑动条取值范围是否反向。 |
**参数:**
- SliderStyle枚举说明
| 名称 | 描述 |
| -------- | -------- |
| OutSet | 滑块在滑轨上。 |
| InSet | 滑块在滑轨内。 |
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| value | number | 否 | 当前进度值。<br/>默认值:0 |
| min | number | 否 | 设置最小值。<br/>默认值:0 |
| max | number | 否 | 设置最大值。<br/>默认值:100 |
| step | number | 否 | 设置Slider滑动跳动值,当设置相应的step时,Slider为间歇滑动。<br/>默认值:1 |
| style | SliderStyle | 否 | 设置Slider的滑块样式。<br/>默认值:SliderStyle.OutSet |
| direction<sup>8+</sup> | [Axis](ts-appendix-enums.md#axis) | 否 | 设置滑动条滑动方向为水平或竖直方向。<br/>默认值:Axis.Horizontal |
| reverse<sup>8+</sup> | boolean | 否 | 设置滑动条取值范围是否反向。<br/>默认值:false |
## SliderStyle枚举说明
| 名称 | 描述 |
| -------- | -------- |
| OutSet | 滑块在滑轨上。 |
| InSet | 滑块在滑轨内。 |
## 属性
不支持触摸热区设置。
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| blockColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | - | 设置滑块的颜色。 |
| trackColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | - | 设置滑轨的背景颜色。 |
| selectedColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | - | 设置滑轨的已滑动颜色。 |
| showSteps | boolean | false | 设置当前是否显示步长刻度值。 |
| showTips | boolean | false | 设置滑动时是否显示气泡提示百分比。 |
| trackThickness | [Length](../../ui/ts-types.md#length) | - | 设置滑轨的粗细。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| blockColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑块的颜色。 |
| trackColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑轨的背景颜色。 |
| selectedColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑轨的已滑动颜色。 |
| showSteps | boolean | 设置当前是否显示步长刻度值。<br/>默认值:false |
| showTips | boolean | 设置滑动时是否显示气泡提示百分比。<br/>默认值:false |
| trackThickness | [Length](../../ui/ts-types.md#length) | 设置滑轨的粗细。 |
## 事件
......@@ -61,13 +58,14 @@ Slider(options:{value?: number, min?: number, max?: number, step?: number, style
| -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;number,&nbsp;mode:&nbsp;SliderChangeMode)&nbsp;=&gt;&nbsp;void) | Slider滑动时触发事件回调。<br/>value:当前进度值。<br/>mode:拖动状态。 |
- SliderChangeMode枚举说明
| 名称 | 值 | 描述 |
| -------- | -------- | -------- |
| Begin | 0 | 用户开始拖动滑块。 |
| Moving | 1 | 用户拖动滑块中。 |
| End | 2 | 用户结束拖动滑块。 |
| Click | 3 | 用户点击滑动条使滑块位置移动。 |
## SliderChangeMode枚举说明
| 名称 | 值 | 描述 |
| -------- | -------- | -------- |
| Begin | 0 | 用户开始拖动滑块。 |
| Moving | 1 | 用户拖动滑块中。 |
| End | 2 | 用户结束拖动滑块。 |
| Click | 3 | 用户点击滑动条使滑块位置移动。 |
## 示例
......
......@@ -3,12 +3,8 @@
作为Text组件的子组件,用于显示行内文本的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -18,23 +14,24 @@
## 接口
Span(content: ResourceStr)
Span(content: string | Resource)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| content | [ResourceStr](../../ui/ts-types.md#resourcestr8) | 是 | - | 文本内容。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| content | string \| [Resource](../../ui/ts-types.md#resource) | 是 | 文本内容。 |
## 属性
通用属性方法仅支持通用文本样式,不支持触摸热区设置。
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md#resourcecolor8)<br/>} | {<br/>type:&nbsp;TextDecorationType.None<br/>color:Color.Black<br/>} | 设置文本装饰线样式及其颜色。 |
| letterSpacing | [Length](../../ui/ts-types.md#length) | - | 设置文本字符间距。 |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | Normal | 设置文本大小写。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| decoration | {<br/>type:&nbsp;[TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md#resourcecolor8)<br/>} | 设置文本装饰线样式及其颜色。<br/>默认值:{<br/>type:&nbsp;TextDecorationType.None<br/>color:Color.Black<br/>} |
| letterSpacing | number \| string | 设置文本字符间距。 |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。<br/>默认值:TextCase.Normal |
## 事件
......@@ -42,7 +39,8 @@ Span(content: ResourceStr)
通用事件仅支持点击事件。
> **说明:**
> 由于Span组件无尺寸信息,因此点击事件返回的ClickEvent对象的target属性无效。
>
> 由于Span组件无尺寸信息,因此点击事件返回的ClickEvent对象的target属性无效。
## 示例
......
......@@ -3,12 +3,8 @@
显示一段文本的组件。
> **说明:**
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -18,34 +14,35 @@
## 接口
Text(content?: ResourceStr)
Text(content?: string | Resource)
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| content | [ResourceStr](../../ui/ts-types.md#resourcestr8) | 否 | '' | 文本内容。包含子组件Span时不生效,显示Span内容,并且此时text组件的样式不生效。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| content | string \| [Resource](../../ui/ts-types.md#resource) | 否 | 文本内容。包含子组件Span时不生效,显示Span内容,并且此时text组件的样式不生效。<br/>默认值:' ' |
## 属性
Text组件除以下属性外同时包含[文本样式设置](ts-universal-attributes-text-style.md)的属性。
除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性:
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置多行文本的文本对齐方式。<br/>默认值:TextAlign.Start |
| textOverflow | {overflow:&nbsp;[TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。<br/>默认值:{overflow:&nbsp;TextOverflow.Clip}<br/>**说明:**<br/>文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。<br />需配合`maxLines`使用,单独设置不生效。 |
| maxLines | number | 设置文本的最大行数。<br />默认值:Infinity<br/>**说明:**<br />默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。 |
| lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 |
| decoration | {<br/>type:&nbsp;TextDecorationType,<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md)<br/>} | 设置文本装饰线样式及其颜色。<br />默认值:{<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>} |
| baselineOffset | number&nbsp;\|&nbsp;string | 设置文本基线的偏移量。 |
| letterSpacing | number&nbsp;\|&nbsp;string | 设置文本字符间距。 |
| minFontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | 设置文本最小显示字号。 |
| maxFontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | 设置文本最大显示字号。 |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。<br />默认值:TextCase.Normal |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。<br />默认值:CopyOptions.None |
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | TextAlign.Start | 设置多行文本的文本对齐方式。 |
| textOverflow | {overflow:&nbsp;[TextOverflow](ts-appendix-enums.md#textoverflow)} | {overflow:&nbsp;TextOverflow.Clip} | 设置文本超长时的显示方式。<br/>**说明:**<br/>文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。<br />需配合`maxLines`使用,单独设置不生效。 |
| maxLines | number | Infinity | 设置文本的最大行数。<br />**说明:**<br />默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。 |
| lineHeight | string&nbsp;\|&nbsp;number&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | - | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 |
| decoration | {<br/>type:&nbsp;TextDecorationType,<br/>color?:&nbsp;[ResourceColor](../../ui/ts-types.md)<br/>} | {<br/>type:&nbsp;TextDecorationType.None,<br/>color:Color.Black<br/>} | 设置文本装饰线样式及其颜色。 |
| baselineOffset | number \| string | - | 设置文本基线的偏移量。 |
| letterSpacing | [Length](../../ui/ts-types.md) | - | 设置文本字符间距。 |
| minFontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | - | 设置文本最小显示字号。 |
| maxFontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md) | - | 设置文本最大显示字号。 |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | TextCase.Normal | 设置文本大小写。 |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | CopyOptions.None | 组件支持设置文本是否可复制粘贴。 |
> **说明:**
> 不支持Text内同时存在文本内容和Span子组件。如果同时存在,只显示Span内的内容。
>
> 不支持Text内同时存在文本内容和Span子组件。如果同时存在,只显示Span内的内容。
## 示例
......
......@@ -3,12 +3,8 @@
滚动选择文本的组件。
> **说明:**
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限列表
>
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件
......@@ -18,27 +14,28 @@
## 接口
TextPicker(options: {range: string[]|Resource, selected?: number, value?: string})
TextPicker(options?: {range: string[]|Resource, selected?: number, value?: string})
根据range指定的选择范围创建文本选择器。
- 参数
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | -------- | -------- | -------- |
| range | string[]&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md#resource类型) | 是 | - | 选择器的数据选择范围。 |
| selected | number | 否 | 0 | 选中项在数组中的index值。 |
| value | string | 否 | 第一个元素值 | 选中项的值,优先级低于selected。 |
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- |
| range | string[]&nbsp;\|&nbsp;[Resource](../../ui/ts-types.md#resource类型) | 是 | 选择器的数据选择范围。 |
| selected | number | 否 | 选中项在数组中的index值。<br/>默认值:0 |
| value | string | 否 | 选中项的值,优先级低于selected。<br/>默认值:第一个元素值 |
## 属性
| 名称 | 参数类型 | 默认值 | 描述 |
| -------- | -------- | -------- | -------- |
| defaultPickerItemHeight | number \| string | - | 默认Picker内容项元素高度。 |
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| defaultPickerItemHeight | number \| string | 默认Picker内容项元素高度。 |
## 事件
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
| 名称 | 描述 |
| -------- | -------- |
| onChange(callback:&nbsp;(value:&nbsp;string,&nbsp;index:&nbsp;number)&nbsp;=&gt;&nbsp;void) | 滑动选中TextPicker文本内容后,触发该回调。<br/>-&nbsp;value:&nbsp;当前选中项的文本。<br/>-&nbsp;index:&nbsp;当前选中项的索引值。 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册