提交 16f2cc93 编写于 作者: 田雨 提交者: Gitee

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

Signed-off-by: N田雨 <tianyu55@huawei.com>
# 页面级变量的状态管理 # 页面级变量的状态管理
@State、@Prop、@Link、@Provide、Consume、@ObjectLink、@Observed和@Watch用于管理页面级变量的状态。 @State、@Prop、@Link、@Provide、@Consume、@ObjectLink、@Observed和@Watch用于管理页面级变量的状态。
请参考[状态变量多种数据类型声明的使用限制](./arkts-restrictions-and-extensions.md)了解@State、@Provide、 @Link和@Consume四种状态变量的约束条件。 请参考[状态变量多种数据类型声明的使用限制](./arkts-restrictions-and-extensions.md)了解@State、@Provide、 @Link和@Consume四种状态变量的约束条件。
......
...@@ -190,6 +190,7 @@ ...@@ -190,6 +190,7 @@
```ts ```ts
// index.ets // index.ets
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
...@@ -234,6 +235,7 @@ ...@@ -234,6 +235,7 @@
```ts ```ts
// second.ets // second.ets
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
......
...@@ -189,6 +189,7 @@ ...@@ -189,6 +189,7 @@
```ts ```ts
// index.ets // index.ets
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
...@@ -233,6 +234,7 @@ ...@@ -233,6 +234,7 @@
```ts ```ts
// second.ets // second.ets
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
@Entry @Entry
......
...@@ -183,6 +183,7 @@ ...@@ -183,6 +183,7 @@
```js ```js
// index.js // index.js
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
export default { export default {
...@@ -200,6 +201,7 @@ ...@@ -200,6 +201,7 @@
```js ```js
// second.js // second.js
// 导入页面路由模块
import router from '@ohos.router'; import router from '@ohos.router';
export default { export default {
......
...@@ -60,7 +60,7 @@ buffer数组的列表。 ...@@ -60,7 +60,7 @@ buffer数组的列表。
## EncodingBlob ## EncodingBlob
证书链数据,在证书链校验时,作为入参传入 带编码格式的证书二进制数组
### 属性 ### 属性
...@@ -1029,7 +1029,7 @@ console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); // 输出全 ...@@ -1029,7 +1029,7 @@ console.info("key hex:" + uint8ArrayToShowStr(encodedKey.data)); // 输出全
getEncoded() : DataBlob getEncoded() : DataBlob
以同步方法,获取二进制形式的密钥内容。 以同步方法,获取二进制形式的密钥内容。公钥格式满足ASN.1语法、X.509规范、DER编码格式。
**系统能力:** SystemCapability.Security.CryptoFramework **系统能力:** SystemCapability.Security.CryptoFramework
...@@ -1065,7 +1065,7 @@ console.info("key encoded:" + Uint8ArrayToShowStr(encodedKey.data)); ...@@ -1065,7 +1065,7 @@ console.info("key encoded:" + Uint8ArrayToShowStr(encodedKey.data));
getEncoded() : DataBlob getEncoded() : DataBlob
以同步方法,获取二进制形式的密钥内容。 以同步方法,获取二进制形式的密钥内容。私钥格式满足ASN.1语法,PKCS#8规范、DER编码方式。
**系统能力:** SystemCapability.Security.CryptoFramework **系统能力:** SystemCapability.Security.CryptoFramework
...@@ -1437,11 +1437,9 @@ keyGenPromise.then( keyPair => { ...@@ -1437,11 +1437,9 @@ keyGenPromise.then( keyPair => {
**密钥转换说明** **密钥转换说明**
1. RSA二进制密钥数据,按keysize(32位) ,nsize(keysize/8), esize(e实际长度),dsize(keysize/8),nval(大数n的二进制数据),eval(大数e的二进制数据),dval(大数d的二进制数据)拼接形成。 1. 非对称密钥(RSA、ECC)的公钥和私钥调用getEncoded()方法后,分别返回X.509格式和PKCS#8格式的二进制数据,此数据可用于跨应用传输或持久化存储。
2. RSA二进制密钥数据中,nsize和dsize为密钥位数/8,esize为具体的实际长度。 2. 当调用convertKey方法将外来二进制数据转换为算法库非对称密钥对象时,公钥应满足ASN.1语法、X.509规范、DER编码格式,私钥应满足ASN.1语法、PKCS#8规范、DER编码格式。
3. RSA私钥数据需要包含keysize,nsize,esize,dsize,nval,eval,dval的全部数据,公钥材料中dsize设置为0,缺省dval的数据。 3. convertKey方法中,公钥和密钥二进制数据非必选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。
4. RSA二进制密钥数据中,keysize、nsize、esize和dsize为32位二进制数据,数据的大小端格式请按设备CPU默认格式,密钥材料(nval、eval、dval)统一为大端格式。
5. convertKey接口中,公钥和私钥二进制数据为可选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。
## cryptoFramework.createCipher ## cryptoFramework.createCipher
......
...@@ -68,7 +68,7 @@ stat(path: string): Promise&lt;Stat&gt; ...@@ -68,7 +68,7 @@ stat(path: string): Promise&lt;Stat&gt;
```js ```js
let filePath = pathDir + "test.txt"; let filePath = pathDir + "test.txt";
fileio.stat(filePath).then(function(stat){ fileio.stat(filePath).then(function(stat){
console.info("getFileInfo succeed:"+ JSON.stringify(stat)); console.info("getFileInfo succeed, the size of file is " + stat.size);
}).catch(function(err){ }).catch(function(err){
console.info("getFileInfo failed with error:"+ err); console.info("getFileInfo failed with error:"+ err);
}); });
...@@ -153,7 +153,7 @@ opendir(path: string): Promise&lt;Dir&gt; ...@@ -153,7 +153,7 @@ opendir(path: string): Promise&lt;Dir&gt;
```js ```js
let dirPath = pathDir + "/testDir"; let dirPath = pathDir + "/testDir";
fileio.opendir(dirPath).then(function(dir){ fileio.opendir(dirPath).then(function(dir){
console.info("opendir succeed:"+ JSON.stringify(dir)); console.info("opendir succeed");
}).catch(function(err){ }).catch(function(err){
console.info("opendir failed with error:"+ err); console.info("opendir failed with error:"+ err);
}); });
...@@ -1178,7 +1178,7 @@ fstat(fd: number): Promise&lt;Stat&gt; ...@@ -1178,7 +1178,7 @@ fstat(fd: number): Promise&lt;Stat&gt;
let filePath = pathDir + "/test.txt"; let filePath = pathDir + "/test.txt";
let fd = fileio.openSync(filePath); let fd = fileio.openSync(filePath);
fileio.fstat(fd).then(function(stat){ fileio.fstat(fd).then(function(stat){
console.info("fstat succeed:"+ JSON.stringify(stat)); console.info("fstat succeed, the size of file is "+ stat.size);
}).catch(function(err){ }).catch(function(err){
console.info("fstat failed with error:"+ err); console.info("fstat failed with error:"+ err);
}); });
...@@ -1525,7 +1525,7 @@ lstat(path: string): Promise&lt;Stat&gt; ...@@ -1525,7 +1525,7 @@ lstat(path: string): Promise&lt;Stat&gt;
```js ```js
let filePath = pathDir + "/test.txt"; let filePath = pathDir + "/test.txt";
fileio.lstat(filePath).then(function(stat){ fileio.lstat(filePath).then(function(stat){
console.info("get link status succeed:"+ JSON.stringify(stat)); console.info("get link status succeed, " + the size of file is + stat.size);
}).catch(function(err){ }).catch(function(err){
console.info("get link status failed with error:"+ err); console.info("get link status failed with error:"+ err);
}); });
...@@ -3166,7 +3166,7 @@ read(): Promise&lt;Dirent&gt; ...@@ -3166,7 +3166,7 @@ read(): Promise&lt;Dirent&gt;
```js ```js
dir.read().then(function (dirent){ dir.read().then(function (dirent){
console.log("read succeed:"+JSON.stringify(dirent)); console.log("read succeed, the name of dirent is " + dirent.name);
}).catch(function(err){ }).catch(function(err){
console.info("read failed with error:"+ err); console.info("read failed with error:"+ err);
}); });
...@@ -3193,7 +3193,7 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void ...@@ -3193,7 +3193,7 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void
dir.read(function (err, dirent) { dir.read(function (err, dirent) {
if (dirent) { if (dirent) {
// do something // do something
console.log("read succeed:"+JSON.stringify(dirent)); console.log("read succeed, the name of file is " + dirent.name);
} }
}); });
``` ```
......
# 鼠标指针 # 鼠标指针
鼠标指针管理模块,用于提供鼠标指针相关属性接口 鼠标指针管理模块,用于查询和设置鼠标指针相关属性
> **说明**: > **说明**:
> >
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
import pointer from '@ohos.multimodalInput.pointer'; import pointer from '@ohos.multimodalInput.pointer';
``` ```
## pointer.setPointerVisibele<sup>9+</sup> ## pointer.setPointerVisible<sup>9+</sup>
setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
设置鼠标指针显示或者隐藏,使用callback异步回调 设置鼠标指针显示或者隐藏,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -24,18 +24,22 @@ setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void ...@@ -24,18 +24,22 @@ setPointerVisible(visible: boolean, callback: AsyncCallback&lt;void&gt;): void
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------------- | | -------- | ------------------------- | ---- | ---------------------------------------- |
| visible | boolean | 是 | 鼠标指针显示或者隐藏状态,true: 鼠标指针显示; false: 鼠标指针隐藏。 | | visible | boolean | 是 | 鼠标指针是否显示。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当设置鼠标显示或隐藏成功,err为undefined,否则为错误对象。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例** **示例**
```js ```js
try { try {
pointer.setPointerVisible(true, (err, data) => { pointer.setPointerVisible(true, (error) => {
if (error) {
console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set pointer visible success`); console.log(`Set pointer visible success`);
}); });
} catch (err) { } catch (error) {
console.log(`Set pointer visible failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -43,7 +47,7 @@ try { ...@@ -43,7 +47,7 @@ try {
setPointerVisible(visible: boolean): Promise&lt;void&gt; setPointerVisible(visible: boolean): Promise&lt;void&gt;
设置鼠标指针显示或者隐藏,使用Promise方式作为异步方法 设置鼠标指针显示或者隐藏,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -51,23 +55,23 @@ setPointerVisible(visible: boolean): Promise&lt;void&gt; ...@@ -51,23 +55,23 @@ setPointerVisible(visible: boolean): Promise&lt;void&gt;
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ------- | ------- | ---- | ---------------------------------------- | | ------- | ------- | ---- | ---------------------------------------- |
| visible | boolean | 是 | 鼠标指针显示或者隐藏状态,true: 鼠标指针显示; false: 鼠标指针隐藏。 | | visible | boolean | 是 | 鼠标指针是否显示。 |
**返回值** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| ------------------- | ------------------- | | ------------------- | ------------------- |
| Promise&lt;void&gt; | Promise实例,用于异步获取结果。 | | Promise&lt;void&gt; | Promise对象。 |
**示例** **示例**
```js ```js
try { try {
pointer.setPointerVisible(false).then(data => { pointer.setPointerVisible(false).then(() => {
console.log(`Set mouse pointer visible success`); console.log(`Set pointer visible success`);
}); });
} catch { } catch (error) {
console.log(`Set mouse pointer visible failed err=${JSON.stringify(data)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -75,7 +79,7 @@ try { ...@@ -75,7 +79,7 @@ try {
isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
获取鼠标指针显示或隐藏状态,使用callback异步回调 获取鼠标指针显示或隐藏状态,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -83,17 +87,21 @@ isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void ...@@ -83,17 +87,21 @@ isPointerVisible(callback: AsyncCallback&lt;boolean&gt;): void
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------- | | -------- | ---------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | AsyncCallback&lt;boolean&gt; | 是 | 回调函数,异步返回鼠标指针显示或隐藏状态。 |
**示例** **示例**
```js ```js
try { try {
pointer.isPointerVisible(visible, (err, data) => { pointer.isPointerVisible((error, visible) => {
console.log(`The mouse pointer visible attributes is ` + visible); if (error) {
console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
}); });
} catch (err) { } catch (error) {
console.log(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Get pointer visible failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -101,7 +109,7 @@ try { ...@@ -101,7 +109,7 @@ try {
isPointerVisible(): Promise&lt;boolean&gt; isPointerVisible(): Promise&lt;boolean&gt;
获取鼠标指针显示或隐藏状态,使用Promise方式作为异步方法 获取鼠标指针显示或隐藏状态,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -109,25 +117,21 @@ isPointerVisible(): Promise&lt;boolean&gt; ...@@ -109,25 +117,21 @@ isPointerVisible(): Promise&lt;boolean&gt;
| 参数 | 说明 | | 参数 | 说明 |
| ---------------------- | ------------------- | | ---------------------- | ------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于异步获取结果。 | | Promise&lt;boolean&gt; | Promise对象,异步返回鼠标指针显示或隐藏状态。 |
**示例** **示例**
```js ```js
try { pointer.isPointerVisible().then((visible) => {
pointer.isPointerVisible().then((data) => { console.log(`Get pointer visible success, visible: ${JSON.stringify(visible)}`);
console.log(`The mouse pointer visible attributes is success. data=${JSON.stringify(data)}`); });
});
} catch (err) {
ponsole.info(`The mouse pointer visible attributes is failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`);
}
``` ```
## pointer.setPointerSpeed<sup>9+</sup> ## pointer.setPointerSpeed<sup>9+</sup>
setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
设置鼠标移动速度,使用callback异步回调 设置鼠标移动速度,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -135,18 +139,22 @@ setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void ...@@ -135,18 +139,22 @@ setPointerSpeed(speed: number, callback: AsyncCallback&lt;void&gt;): void
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------- | | -------- | ------------------------- | ---- | ------------------------------------- |
| speed | number | 是 | 鼠标移动速度设置挡位值1-11,最大值:11,最小值:1,标准值:5。 | | speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。当设置鼠标速度成功,err为undefined,否则为错误对象。 | | callback | AysncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例** **示例**
```js ```js
try { try {
pointer.setPointerSpeed(5, (err, data) => { pointer.setPointerSpeed(5, (error) => {
if (error) {
console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Set pointer speed success`); console.log(`Set pointer speed success`);
}); });
} catch (err) { } catch (err) {
console.log(`Set pointer speed failed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -154,7 +162,7 @@ try { ...@@ -154,7 +162,7 @@ try {
setPointerSpeed(speed: number): Promise&lt;void&gt; setPointerSpeed(speed: number): Promise&lt;void&gt;
设置鼠标移动速度,使用Promise异步回调 设置鼠标移动速度,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -162,23 +170,23 @@ setPointerSpeed(speed: number): Promise&lt;void&gt; ...@@ -162,23 +170,23 @@ setPointerSpeed(speed: number): Promise&lt;void&gt;
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ----------------------------------- | | ----- | ------ | ---- | ----------------------------------- |
| speed | number | 是 | 鼠标移动速度设置挡位值1-11,最大值:11,最小值:1,标准值:5。 | | speed | number | 是 | 鼠标移动速度,范围1-11,默认为5。 |
**返回值** **返回值**
| 参数 | 说明 | | 参数 | 说明 |
| ------------------- | ---------------- | | ------------------- | ---------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | Promise对象。 |
**示例** **示例**
```js ```js
try { try {
pointer.setPointerSpeed(5).then(data => { pointer.setPointerSpeed(5).then(() => {
console.log(`Set pointer speed success`); console.log(`Set pointer speed success`);
}); });
} catch (err) { } catch (error) {
console.log(`Set pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -186,7 +194,7 @@ try { ...@@ -186,7 +194,7 @@ try {
getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void
获取当前鼠标移动速度,使用callback异步回调 获取鼠标移动速度,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -194,17 +202,21 @@ getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void ...@@ -194,17 +202,21 @@ getPointerSpeed(callback: AsyncCallback&lt;number&gt;): void
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------- | | -------- | --------------------------- | ---- | -------------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,异步返回鼠标移动速度。 |
**示例** **示例**
```js ```js
try { try {
pointer.getPointerSpeed(speed, (err, data) => { pointer.getPointerSpeed(speed, (error, speed) => {
console.log(`The pointer speed is ` + speed); if (error) {
console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
}); });
} catch (err) { } catch (err) {
console.log(`Failed to get the pointer speed. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -212,7 +224,7 @@ try { ...@@ -212,7 +224,7 @@ try {
getPointerSpeed(): Promise&lt;number&gt; getPointerSpeed(): Promise&lt;number&gt;
获取当前鼠标移动速度,使用Promise异步回调 获取当前鼠标移动速度,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -220,17 +232,17 @@ getPointerSpeed(): Promise&lt;number&gt; ...@@ -220,17 +232,17 @@ getPointerSpeed(): Promise&lt;number&gt;
| 参数 | 说明 | | 参数 | 说明 |
| --------------------- | ------------------- | | --------------------- | ------------------- |
| Promise&lt;number&gt; | Promise实例,用于异步获取结果。 | | Promise&lt;number&gt; | Promise实例,异步返回鼠标移动速度。 |
**示例** **示例**
```js ```js
try { try {
pointer.getPointerSpeed().then(data => { pointer.getPointerSpeed().then(speed => {
console.log(`Get pointer speed success. data=${JSON.stringify(data)}`); console.log(`Get pointer speed success, speed: ${JSON.stringify(speed)}`);
}); });
} catch (err) { } catch (error) {
console.log(`Get pointer speed failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Get pointer speed failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
``` ```
...@@ -238,7 +250,7 @@ try { ...@@ -238,7 +250,7 @@ try {
getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): void
获取鼠标样式类型,使用callback异步回调 获取鼠标样式类型,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -246,29 +258,27 @@ getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;): ...@@ -246,29 +258,27 @@ getPointerStyle(windowId: number, callback: AsyncCallback&lt;PointerStyle&gt;):
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | -------------- | | -------- | ---------------------------------------- | ---- | -------------- |
| windowId | number | 是 | 输入设备的窗口id。 | | windowId | number | 是 | 窗口id。 |
| callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | 是 | 回调函数,异步返回查询结果。 | | callback | AsyncCallback&lt;[PointerStyle](#pointerstyle9)&gt; | 是 | 回调函数,异步返回鼠标样式类型。 |
**示例** **示例**
```js ```js
// 获取设备的鼠标样式。
import window from '@ohos.window'; import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => { window.getTopWindow((error, win) => {
windowClass = data; win.getProperties((error, properties) => {
windowClass.getProperties((err, data) => { var windowId = properties.id;
var windowId = data.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
} }
try { try {
pointer.getPointerStyle(windowId, (err, ret) => { pointer.getPointerStyle(windowId, (error, style) => {
console.log(`The mouse pointer style is: ` + ret); console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
}); });
} catch (err) { } catch (error) {
console.log(`Failed to get the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
}); });
}); });
...@@ -278,7 +288,7 @@ window.getTopWindow((err, data) => { ...@@ -278,7 +288,7 @@ window.getTopWindow((err, data) => {
getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt; getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
获取鼠标样式类型,使用Promise方式作为异步方法 获取鼠标样式类型,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -286,28 +296,26 @@ getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt; ...@@ -286,28 +296,26 @@ getPointerStyle(windowId: number): Promise&lt;PointerStyle&gt;
| 参数 | 说明 | | 参数 | 说明 |
| ---------------------------------------- | ------------------- | | ---------------------------------------- | ------------------- |
| Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise实例,用于异步获取结果。 | | Promise&lt;[PointerStyle](#pointerstyle9)&gt; | Promise实例,异步返回鼠标样式类型。 |
**示例** **示例**
```js ```js
// 获取设备的鼠标样式。
import window from '@ohos.window'; import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => { window.getTopWindow((error, win) => {
windowClass = data; win.getProperties((error, properties) => {
windowClass.getProperties((err, data) => { var windowId = properties.id;
var windowId = data.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
} }
try { try {
pointer.getPointerStyle(windowId).then((ret) => { pointer.getPointerStyle(windowId).then((style) => {
console.log(`The mouse pointer style is: ` + ret); console.log(`Get pointer style success, style: ${JSON.stringify(style)}`);
}); });
} catch (err) { } catch (error) {
console.log(`Get pointer style failed err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Get pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
}); });
}); });
...@@ -317,7 +325,7 @@ window.getTopWindow((err, data) => { ...@@ -317,7 +325,7 @@ window.getTopWindow((err, data) => {
setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCallback&lt;void&gt;): void
设置鼠标的样式类型,使用callback异步回调 设置鼠标样式类型,使用AsyncCallback异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -325,30 +333,28 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCal ...@@ -325,30 +333,28 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle, callback: AsyncCal
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ------------ | ------------------------------ | ---- | ----------------------------------- | | ------------ | ------------------------------ | ---- | ----------------------------------- |
| windowId | number | 是 | 输入设备的窗口id。 | | windowId | number | 是 | 窗口id。 |
| pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 | | pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 |
| callback | AysncCallback&lt;void&gt; | 是 | 回调函数。当设置样式成功,err为undefined,否则为错误对象。 | | callback | AysncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例** **示例**
```js ```js
// 设置设备的鼠标样式。
import window from '@ohos.window'; import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => { window.getTopWindow((error, win) => {
windowClass = data; win.getProperties((error, properties) => {
windowClass.getProperties((err, data) => { var windowId = properties.id;
var windowId = data.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
} }
try { try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, (err) => { pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS, error => {
console.log(`Successfully set mouse pointer style`); console.log(`Set pointer style success`);
}); });
} catch (err) { } catch (error) {
console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
}); });
}); });
...@@ -357,7 +363,7 @@ window.getTopWindow((err, data) => { ...@@ -357,7 +363,7 @@ window.getTopWindow((err, data) => {
setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt; setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&gt;
设置鼠标的样式类型,使用Promise方式作为异步方法 设置鼠标样式类型,使用Promise异步方式返回结果
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -365,37 +371,35 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&g ...@@ -365,37 +371,35 @@ setPointerStyle(windowId: number, pointerStyle: PointerStyle): Promise&lt;void&g
| 参数 | 类型 | 必填 | 说明 | | 参数 | 类型 | 必填 | 说明 |
| ------------------- | ------------------------------ | ---- | ---------------- | | ------------------- | ------------------------------ | ---- | ---------------- |
| windowId | number | 是 | 输入设备的窗口id。 | | windowId | number | 是 | 窗口id。 |
| pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 | | pointerStyle | [PointerStyle](#pointerstyle9) | 是 | 鼠标样式id。 |
| Promise&lt;void&gt; | void | 是 | 无返回结果的Promise对象。 | | Promise&lt;void&gt; | void | 是 | Promise对象。 |
**示例** **示例**
```js ```js
// 设置设备的鼠标样式。
import window from '@ohos.window'; import window from '@ohos.window';
var windowClass = null;
window.getTopWindow((err, data) => { window.getTopWindow((error, win) => {
windowClass = data; win.getProperties((error, properties) => {
windowClass.getProperties((err, data) => { var windowId = properties.id;
var windowId = data.id;
if (windowId < 0) { if (windowId < 0) {
console.log(`Invalid windowId`); console.log(`Invalid windowId`);
return; return;
} }
try { try {
pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => { pointer.setPointerStyle(windowId, pointer.PointerStyle.CROSS).then(() => {
console.log(`Successfully set mouse pointer style`); console.log(`Set pointer style success`);
}); });
} catch (err) { } catch (error) {
console.log(`Failed to set the pointer style. err=${JSON.stringify(err)}, msg=${JSON.stringify(message)}`); console.log(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
} }
}); });
}); });
``` ```
## PointerStyle<sup>9+</sup> ## PointerStyle<sup>9+</sup>
定义鼠标样式类型。 鼠标样式类型。
**系统能力**:SystemCapability.MultimodalInput.Input.Pointer **系统能力**:SystemCapability.MultimodalInput.Input.Pointer
...@@ -440,5 +444,3 @@ window.getTopWindow((err, data) => { ...@@ -440,5 +444,3 @@ window.getTopWindow((err, data) => {
| MIDDLE_BTN_SOUTH_EAST | 36 | 向东南滚动 | | MIDDLE_BTN_SOUTH_EAST | 36 | 向东南滚动 |
| MIDDLE_BTN_SOUTH_WEST | 37 | 向西南滚动 | | MIDDLE_BTN_SOUTH_WEST | 37 | 向西南滚动 |
| MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | 四向锥形移动 | | MIDDLE_BTN_NORTH_SOUTH_WEST_EAST | 38 | 四向锥形移动 |
\ No newline at end of file
...@@ -73,3 +73,5 @@ struct AttrAnimationExample { ...@@ -73,3 +73,5 @@ struct AttrAnimationExample {
} }
} }
``` ```
![animation](figures/animation.gif)
\ No newline at end of file
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
**参数:** **参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ------- | ----------------------------------- | ---- | ------------- | | ------- | ----------------------------------- | ---- | ------------- |
| label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 | | label | [ResourceStr](ts-types.md#resourcestr) | 否 | 按钮文本内容。 |
| options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 | | options | { type?: ButtonType, stateEffect?: boolean } | 否 | 见方法1参数说明。 |
## 属性 ## 属性
...@@ -89,9 +89,6 @@ struct ButtonExample { ...@@ -89,9 +89,6 @@ struct ButtonExample {
Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 }) Text('loading').fontSize(12).fontColor(0xffffff).margin({ left: 5, right: 12 })
}.alignItems(VerticalAlign.Center).width(90).height(40) }.alignItems(VerticalAlign.Center).width(90).height(40)
}.backgroundColor(0x317aff) }.backgroundColor(0x317aff)
.onClick((event: ClickEvent) => {
AlertDialog.show({ message: 'The login is successful' })
})
Button('Disable', { type: ButtonType.Capsule, stateEffect: false }).opacity(0.4) Button('Disable', { type: ButtonType.Capsule, stateEffect: false }).opacity(0.4)
.backgroundColor(0x317aff).width(90) .backgroundColor(0x317aff).width(90)
...@@ -112,3 +109,4 @@ struct ButtonExample { ...@@ -112,3 +109,4 @@ struct ButtonExample {
} }
``` ```
![button](figures/button.gif)
\ No newline at end of file
...@@ -7,10 +7,6 @@ ...@@ -7,10 +7,6 @@
> 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 该组件从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 子组件 ## 子组件
...@@ -55,58 +51,34 @@ DatePicker(options?: {start?: Date, end?: Date, selected?: Date}) ...@@ -55,58 +51,34 @@ DatePicker(options?: {start?: Date, end?: Date, selected?: Date})
## 示例 ## 示例
### 日期选择器(显示农历)
```ts ```ts
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct DatePickerExample01 { struct DatePickerExample {
@State isLunar: boolean = false
private selectedDate: Date = new Date('2021-08-08') private selectedDate: Date = new Date('2021-08-08')
build() { build() {
Column() { Column() {
DatePicker({ Button('切换公历农历')
start: new Date('1970-1-1'), .margin({ top: 30 })
end: new Date('2100-1-1'), .onClick(() => {
selected: this.selectedDate, this.isLunar = !this.isLunar
}) })
.lunar(true)
.onChange((date: DatePickerResult) => {
console.info('select current date is: ' + JSON.stringify(date))
})
}.width('100%')
}
}
```
![zh-cn_image_0000001251279761](figures/zh-cn_image_0000001251279761.gif)
### 日期选择器(不显示农历)
```ts
// xxx.ets
@Entry
@Component
struct DatePickerExample02 {
private selectedDate: Date = new Date('2021-08-08')
build() {
Column() {
DatePicker({ DatePicker({
start: new Date('1970-1-1'), start: new Date('1970-1-1'),
end: new Date('2100-1-1'), end: new Date('2100-1-1'),
selected: this.selectedDate, selected: this.selectedDate,
}) })
.lunar(false) .lunar(this.isLunar)
.onChange((date: DatePickerResult) => { .onChange((value: DatePickerResult) => {
console.info('select current date is: ' + JSON.stringify(date)) this.selectedDate.setFullYear(value.year, value.month, value.day)
console.info('select current date is: ' + JSON.stringify(value))
}) })
}.width('100%') }.width('100%')
} }
} }
``` ```
![zh-cn_image_0000001251092975](figures/zh-cn_image_0000001251092975.gif)
...@@ -22,8 +22,8 @@ ImageAnimator() ...@@ -22,8 +22,8 @@ ImageAnimator()
| 参数名称 | 参数类型 |参数描述 | | 参数名称 | 参数类型 |参数描述 |
| ---------- | ----------------------- |-------- | | ---------- | ----------------------- |-------- |
| images | Array&lt;[ImageFrameInfo](imageframeinfo对象说明)&gt; | 设置图片帧信息集合。每一帧的帧信息(ImageFrameInfo)包含图片路径、图片大小、图片位置和图片播放时长信息,详见ImageFrameInfo属性说明。<br/>默认值:[] | | images | Array&lt;[ImageFrameInfo](#imageframeinfo对象说明)&gt; | 设置图片帧信息集合。每一帧的帧信息(ImageFrameInfo)包含图片路径、图片大小、图片位置和图片播放时长信息,详见ImageFrameInfo属性说明。<br/>默认值:[] |
| state | [AnimationStatus](ts-appendix-enums.md#animationstatus) |默认为初始状态,用于控制播放状态。<br/>默认值:AnimationStatus.Initial | | state | [AnimationStatus](ts-appendix-enums.md#animationstatus) | 默认为初始状态,用于控制播放状态。<br/>默认值:AnimationStatus.Initial |
| duration | number | 单位为毫秒,默认时长为1000ms;duration为0时,不播放图片;值的改变只会在下一次循环开始时生效;当images中任意一帧图片设置了单独的duration后,该属性设置无效。<br/>默认值:1000 | | duration | number | 单位为毫秒,默认时长为1000ms;duration为0时,不播放图片;值的改变只会在下一次循环开始时生效;当images中任意一帧图片设置了单独的duration后,该属性设置无效。<br/>默认值:1000 |
| reverse | boolean | 设置播放顺序。false表示从第1张图片播放到最后1张图片;&nbsp;true表示从最后1张图片播放到第1张图片。<br/>默认值:false | | reverse | boolean | 设置播放顺序。false表示从第1张图片播放到最后1张图片;&nbsp;true表示从最后1张图片播放到第1张图片。<br/>默认值:false |
| fixedSize | boolean | 设置图片大小是否固定为组件大小。&nbsp;true表示图片大小与组件大小一致,此时设置图片的width&nbsp;、height&nbsp;、top&nbsp;和left属性是无效的。false表示每一张图片的width&nbsp;、height&nbsp;、top和left属性都要单独设置。<br/>默认值:true | | fixedSize | boolean | 设置图片大小是否固定为组件大小。&nbsp;true表示图片大小与组件大小一致,此时设置图片的width&nbsp;、height&nbsp;、top&nbsp;和left属性是无效的。false表示每一张图片的width&nbsp;、height&nbsp;、top和left属性都要单独设置。<br/>默认值:true |
...@@ -49,7 +49,7 @@ ImageAnimator() ...@@ -49,7 +49,7 @@ ImageAnimator()
| -------- | -------- | | -------- | -------- |
| onStart(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画开始播放时触发。 | | onStart(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画开始播放时触发。 |
| onPause(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画暂停播放时触发。 | | onPause(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画暂停播放时触发。 |
| onRepeat(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画重播放时触发。 | | onRepeat(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画重播放时触发。 |
| onCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画取消播放时触发。 | | onCancel(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画取消播放时触发。 |
| onFinish(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画播放完成时触发。 | | onFinish(event:&nbsp;()&nbsp;=&gt;&nbsp;void) | 状态回调,动画播放完成时触发。 |
...@@ -66,47 +66,46 @@ struct ImageAnimatorExample { ...@@ -66,47 +66,46 @@ struct ImageAnimatorExample {
@State iterations: number = 1 @State iterations: number = 1
build() { build() {
Column({ space:5 }) { Column({ space: 10 }) {
ImageAnimator() ImageAnimator()
.images([ .images([
{ {
// comment文件夹与pages同级 src: $r('app.media.img1'),
src: '/comment/bg1.jpg',
duration: 500, duration: 500,
width: 325, width: 170,
height: 200, height: 120,
top: 0, top: 0,
left: 0 left: 0
}, },
{ {
src: '/comment/bg2.jpg', src: $r('app.media.img2'),
duration: 500, duration: 500,
width: 325, width: 170,
height: 200, height: 120,
top: 0, top: 0,
left: 0 left: 170
}, },
{ {
src: $r('app.media.bg3'), src: $r('app.media.img3'),
duration: 500, duration: 500,
width: 325, width: 170,
height: 200, height: 120,
top: 0, top: 120,
left: 0 left: 170
}, },
{ {
src: $rawfile('bg4.jpg'), src: $r('app.media.img4'),
duration: 500, duration: 500,
width: 325, width: 170,
height: 200, height: 120,
top: 0, top: 120,
left: 0 left: 0
} }
]) ])
.state(this.state).reverse(this.reverse).fixedSize(false).preDecode(2) .state(this.state).reverse(this.reverse).fixedSize(false).preDecode(2)
.fillMode(FillMode.None).iterations(this.iterations).width(325).height(210) .fillMode(FillMode.None).iterations(this.iterations).width(340).height(240)
.margin({top:100}) .margin({ top: 100 })
.onStart(() => { // 当帧动画开始播放后触发 .onStart(() => {
console.info('Start') console.info('Start')
}) })
.onPause(() => { .onPause(() => {
...@@ -118,35 +117,34 @@ struct ImageAnimatorExample { ...@@ -118,35 +117,34 @@ struct ImageAnimatorExample {
.onCancel(() => { .onCancel(() => {
console.info('Cancel') console.info('Cancel')
}) })
.onFinish(() => { // 当帧动画播放完成后触发 .onFinish(() => {
this.state = AnimationStatus.Stopped
console.info('Finish') console.info('Finish')
}) })
Row() { Row() {
Button('start').width(100).padding(5).onClick(() => { Button('start').width(100).padding(5).onClick(() => {
this.state = AnimationStatus.Running this.state = AnimationStatus.Running
}) }).margin(5)
Button('pause').width(100).padding(5).onClick(() => { Button('pause').width(100).padding(5).onClick(() => {
this.state = AnimationStatus.Paused this.state = AnimationStatus.Paused // 显示当前帧图片
}) }).margin(5)
Button('stop').width(100).padding(5).onClick(() => { Button('stop').width(100).padding(5).onClick(() => {
this.state = AnimationStatus.Stopped this.state = AnimationStatus.Stopped // 显示动画的起始帧图片
}) }).margin(5)
} }
Row() { Row() {
Button('reverse').width(100).padding(5).onClick(() => { Button('reverse').width(100).padding(5).onClick(() => {
this.reverse = !this.reverse this.reverse = !this.reverse
}) }).margin(5)
Button('once').width(100).padding(5).onClick(() => { Button('once').width(100).padding(5).onClick(() => {
this.iterations = 1 this.iterations = 1
}) }).margin(5)
Button('iteration').width(100).padding(5).onClick(() => { Button('infinite').width(100).padding(5).onClick(() => {
this.iterations = -1 this.iterations = -1 // 无限循环播放
}) }).margin(5)
} }
}.width('100%').height('100%').backgroundColor(0xF1F3F5) }.width('100%').height('100%')
} }
} }
``` ```
![zh-cn_image_0000001219662643](figures/zh-cn_image_0000001219662643.gif)
...@@ -65,9 +65,9 @@ stop() ...@@ -65,9 +65,9 @@ stop()
@Entry @Entry
@Component @Component
struct Second { struct Second {
@State accumulateTime: number = 0; @State accumulateTime: number = 0
// 导入对象 // 导入对象
controller: TextClockController = new TextClockController(); controller: TextClockController = new TextClockController()
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Current milliseconds is ' + this.accumulateTime) Text('Current milliseconds is ' + this.accumulateTime)
...@@ -76,7 +76,7 @@ struct Second { ...@@ -76,7 +76,7 @@ struct Second {
TextClock({ timeZoneOffset: -8, controller: this.controller }) TextClock({ timeZoneOffset: -8, controller: this.controller })
.format('hms') .format('hms')
.onDateChange((value: number) => { .onDateChange((value: number) => {
this.accumulateTime = value; this.accumulateTime = value
}) })
.margin(20) .margin(20)
.fontSize(30) .fontSize(30)
...@@ -84,12 +84,12 @@ struct Second { ...@@ -84,12 +84,12 @@ struct Second {
.margin({ bottom: 10 }) .margin({ bottom: 10 })
.onClick(() => { .onClick(() => {
// 启动文本时钟 // 启动文本时钟
this.controller.start(); this.controller.start()
}) })
Button("stop TextClock") Button("stop TextClock")
.onClick(() => { .onClick(() => {
// 停止文本时钟 // 停止文本时钟
this.controller.stop(); this.controller.stop()
}) })
} }
.width('100%') .width('100%')
......
# TextPicker # TextPicker
滚动选择文本的组件。 滑动选择文本内容的组件。
> **说明:** > **说明:**
> >
...@@ -23,14 +23,14 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin ...@@ -23,14 +23,14 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | string[]&nbsp;\|&nbsp;[Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择列表。 | | range | string[]&nbsp;\|&nbsp;[Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择列表。 |
| selected | number | 否 | 设置默认选中项在数组中的index值。<br/>默认值:0 | | selected | number | 否 | 设置默认选中项在数组中的索引值。<br/>默认值:0 |
| value | string | 否 | 设置默认选中项的值,优先级低于selected。<br/>默认值:第一个元素值 | | value | string | 否 | 设置默认选中项的值,优先级低于selected。<br/>默认值:第一个元素值 |
## 属性 ## 属性
| 名称 | 参数类型 | 描述 | | 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- | | -------- | -------- | -------- |
| defaultPickerItemHeight | number \| string | 默认Picker内容项元素高度。 | | defaultPickerItemHeight | number \| string | 设置Picker各选择项的高度。 |
## 事件 ## 事件
...@@ -53,7 +53,7 @@ struct TextPickerExample { ...@@ -53,7 +53,7 @@ struct TextPickerExample {
build() { build() {
Column() { Column() {
TextPicker({range: this.fruits, selected: this.select}) TextPicker({ range: this.fruits, selected: this.select })
.onChange((value: string, index: number) => { .onChange((value: string, index: number) => {
console.info('Picker item changed, value: ' + value + ', index: ' + index) console.info('Picker item changed, value: ' + value + ', index: ' + index)
}) })
......
...@@ -71,11 +71,11 @@ reset() ...@@ -71,11 +71,11 @@ reset()
@Component @Component
struct TextTimerExample { struct TextTimerExample {
textTimerController: TextTimerController = new TextTimerController() textTimerController: TextTimerController = new TextTimerController()
@State format: string = 'HH:mm:ss.SS' @State format: string = 'mm:ss.SS'
build() { build() {
Column() { Column() {
TextTimer({controller: this.textTimerController}) TextTimer({ controller: this.textTimerController, isCountDown: true, count: 30000 })
.format(this.format) .format(this.format)
.fontColor(Color.Black) .fontColor(Color.Black)
.fontSize(50) .fontSize(50)
...@@ -84,14 +84,14 @@ struct TextTimerExample { ...@@ -84,14 +84,14 @@ struct TextTimerExample {
}) })
Row() { Row() {
Button("start").onClick(() => { Button("start").onClick(() => {
this.textTimerController.start(); this.textTimerController.start()
}); })
Button("pause").onClick(() => { Button("pause").onClick(() => {
this.textTimerController.pause(); this.textTimerController.pause()
}); })
Button("reset").onClick(() => { Button("reset").onClick(() => {
this.textTimerController.reset(); this.textTimerController.reset()
}); })
} }
} }
} }
......
# TimePicker # TimePicker
动选择时间的组件。 动选择时间的组件。
> **说明:** > **说明:**
> >
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
TimePicker(options?: {selected?: Date}) TimePicker(options?: {selected?: Date})
默认以00:00至23:59的时间区间创建滑动选择器。 默认以24小时的时间区间创建滑动选择器。
**参数:** **参数:**
...@@ -55,20 +55,25 @@ TimePicker(options?: {selected?: Date}) ...@@ -55,20 +55,25 @@ TimePicker(options?: {selected?: Date})
@Entry @Entry
@Component @Component
struct TimePickerExample { struct TimePickerExample {
@State isMilitaryTime: boolean = false
private selectedTime: Date = new Date('2022-07-22T08:00:00') private selectedTime: Date = new Date('2022-07-22T08:00:00')
build() { build() {
Column() { Column() {
Button('切换12小时制/24小时制')
.margin({ top: 30 })
.onClick(() => {
this.isMilitaryTime = !this.isMilitaryTime
})
TimePicker({ TimePicker({
selected: this.selectedTime, selected: this.selectedTime,
}) })
.useMilitaryTime(true) .useMilitaryTime(this.isMilitaryTime)
.onChange((date: TimePickerResult) => { .onChange((value: TimePickerResult) => {
console.info('select current date is: ' + JSON.stringify(date)) this.selectedTime.setHours(value.hour, value.minute)
console.info('select current date is: ' + JSON.stringify(value))
}) })
}.width('100%') }.width('100%')
} }
} }
``` ```
![zh-cn_image_0000001251292933](figures/zh-cn_image_0000001251292933.gif)
...@@ -23,7 +23,7 @@ Toggle(options: { type: ToggleType, isOn?: boolean }) ...@@ -23,7 +23,7 @@ Toggle(options: { type: ToggleType, isOn?: boolean })
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ---- | ---------- | -----| -------------- | | ---- | ---------- | -----| -------------- |
| type | ToggleType | 是 | 开关类型。 | | type | [ToggleType](#toggletype枚举说明) | 是 | 开关类型。 |
| isOn | boolean | 否 | 开关是否打开,true:打开,false:关闭。<br/>默认值:false | | isOn | boolean | 否 | 开关是否打开,true:打开,false:关闭。<br/>默认值:false |
......
...@@ -162,3 +162,4 @@ struct AlphabetIndexerSample { ...@@ -162,3 +162,4 @@ struct AlphabetIndexerSample {
} }
``` ```
![alphabet](figures/alphabet.gif)
\ No newline at end of file
...@@ -61,8 +61,8 @@ ...@@ -61,8 +61,8 @@
@Entry @Entry
@Component @Component
struct BadgeExample { struct BadgeExample {
@State counts: number = 1; @State counts: number = 1
@State message: string = 'new'; @State message: string = 'new'
build() { build() {
Column() { Column() {
...@@ -77,7 +77,7 @@ struct BadgeExample { ...@@ -77,7 +77,7 @@ struct BadgeExample {
}) { }) {
Button('message') Button('message')
.onClick(() => { .onClick(() => {
this.counts++; this.counts++
}) })
.width(100).height(50).backgroundColor(0x317aff) .width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50) }.width(100).height(50)
...@@ -91,7 +91,7 @@ struct BadgeExample { ...@@ -91,7 +91,7 @@ struct BadgeExample {
}) { }) {
Button('message') Button('message')
.onClick(() => { .onClick(() => {
this.counts++; this.counts++
}) })
.width(100).height(50).backgroundColor(0x317aff) .width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50) }.width(100).height(50)
...@@ -106,7 +106,7 @@ struct BadgeExample { ...@@ -106,7 +106,7 @@ struct BadgeExample {
}) { }) {
Button('message') Button('message')
.onClick(() => { .onClick(() => {
this.counts++; this.counts++
}) })
.width(100).height(50).backgroundColor(0x317aff) .width(100).height(50).backgroundColor(0x317aff)
}.width(100).height(50) }.width(100).height(50)
......
# Flex # Flex
应用弹性方式布局子组件的容器组件。 弹性方式布局子组件的容器组件。
> **说明:** > **说明:**
> - 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > - 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
> - Flex组件在设置flexShrink、flexGrow时存在二次布局过程,因此在对性能有严格要求的场景下建议使用[Column](ts-container-column.md)、[Row](ts-container-row.md)代替。 > - Flex组件在渲染时存在二次布局过程,因此在对性能有严格要求的场景下建议使用[Column](ts-container-column.md)、[Row](ts-container-row.md)代替。
## 权限列表 ## 权限列表
......
...@@ -49,7 +49,7 @@ Navigator(value?: {target: string, type?: NavigationType}) ...@@ -49,7 +49,7 @@ Navigator(value?: {target: string, type?: NavigationType})
@Entry @Entry
@Component @Component
struct NavigatorExample { struct NavigatorExample {
@State active: boolean = false; @State active: boolean = false
@State Text: object = {name: 'news'} @State Text: object = {name: 'news'}
build() { build() {
...@@ -63,7 +63,7 @@ struct NavigatorExample { ...@@ -63,7 +63,7 @@ struct NavigatorExample {
Text('Back to previous page').width('100%').textAlign(TextAlign.Center) Text('Back to previous page').width('100%').textAlign(TextAlign.Center)
}.active(this.active) }.active(this.active)
.onClick(() => { .onClick(() => {
this.active = true; this.active = true
}) })
}.height(150).width(350).padding(35) }.height(150).width(350).padding(35)
} }
...@@ -78,7 +78,7 @@ import router from '@ohos.router' ...@@ -78,7 +78,7 @@ import router from '@ohos.router'
@Component @Component
struct DetailExample { struct DetailExample {
// 接收Navigator.ets的传参 // 接收Navigator.ets的传参
@State text: any = router.getParams().text; @State text: any = router.getParams().text
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
......
...@@ -58,7 +58,7 @@ Panel(show: boolean) ...@@ -58,7 +58,7 @@ Panel(show: boolean)
| 名称 | 功能描述 | | 名称 | 功能描述 |
| -------- | -------- | | -------- | -------- |
| onChange(event:&nbsp;(width:&nbsp;number,&nbsp;height:&nbsp;number,&nbsp;mode:&nbsp;PanelMode)&nbsp;=&gt;&nbsp;void) | 当可滑动面板发生状态变化时触发,&nbsp;返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 | | 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。 | | onHeightChange(callback: (value: number) => void)<sup>9+</sup> |当可滑动面板发生高度变化时触发,返回的height值为内容区高度值,默认返回值单位为px。当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。因用户体验设计原因,panel最高只能滑到 fullHeight-8vp。 |
## 示例 ## 示例
......
...@@ -180,3 +180,5 @@ struct SwiperExample { ...@@ -180,3 +180,5 @@ struct SwiperExample {
} }
} }
``` ```
![swiper](figures/swiper.gif)
\ No newline at end of file
...@@ -113,3 +113,4 @@ struct TabContentExample { ...@@ -113,3 +113,4 @@ struct TabContentExample {
} }
``` ```
![tabContent](figures/tabContent.gif)
\ No newline at end of file
...@@ -88,3 +88,11 @@ struct AnimateToExample { ...@@ -88,3 +88,11 @@ struct AnimateToExample {
} }
} }
``` ```
示意图:
![animation](figures/animation.PNG)
点击第一个按钮播放改变按钮大小的动画,点击第二个按钮播放按钮顺时针旋转90度的动画。
![animation1](figures/animation1.PNG)
\ No newline at end of file
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
> 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 权限
## ActionSheet.show ## ActionSheet.show
...@@ -21,10 +17,10 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp ...@@ -21,10 +17,10 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | -------------------------- | ------- | ----------------------------- | | ---------- | -------------------------- | ------- | ----------------------------- |
| title | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 是 | 弹窗标题。 | | title | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗标题。 |
| message | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 是 | 弹窗内容。 | | message | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗内容。 |
| autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true | | autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true |
| confirm | {<br/>value:&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 确认按钮的文本内容和点击回调。<br>默认值:<br/>value:按钮文本内容。<br/>action:&nbsp;按钮选中时的回调。 | | confirm | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 确认按钮的文本内容和点击回调。<br>默认值:<br/>value:按钮文本内容。<br/>action:&nbsp;按钮选中时的回调。 |
| cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 | | cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 |
| alignment | [DialogAlignment](ts-methods-custom-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Bottom | | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Bottom |
| offset | {<br/>dx:&nbsp;Length,<br/>dy:&nbsp;Length<br/>} | 否 | 弹窗相对alignment所在位置的偏移量。{<br/>dx:&nbsp;0,<br/>dy:&nbsp;0<br/>} | | offset | {<br/>dx:&nbsp;Length,<br/>dy:&nbsp;Length<br/>} | 否 | 弹窗相对alignment所在位置的偏移量。{<br/>dx:&nbsp;0,<br/>dy:&nbsp;0<br/>} |
...@@ -34,8 +30,8 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp ...@@ -34,8 +30,8 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
| ------ | ------------------------------------------------------------ | ---- | ----------------- | | ------ | ------------------------------------------------------------ | ---- | ----------------- |
| title | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 是 | 选项的文本内容。 | | title | [ResourceStr](ts-types.md#resourcestr) | 是 | 选项的文本内容。 |
| icon | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 否 | 选项的图标,默认无图标显示。 | | icon | [ResourceStr](ts-types.md#resourcestr) | 否 | 选项的图标,默认无图标显示。 |
| action | ()=&gt;void | 是 | 选项选中的回调。 | | action | ()=&gt;void | 是 | 选项选中的回调。 |
...@@ -43,7 +39,6 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp ...@@ -43,7 +39,6 @@ show(value: {&nbsp;title: string&nbsp;|&nbsp;Resource,&nbsp;message: string&nbsp
```ts ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct ActionSheetExample { struct ActionSheetExample {
...@@ -54,29 +49,35 @@ struct ActionSheetExample { ...@@ -54,29 +49,35 @@ struct ActionSheetExample {
ActionSheet.show({ ActionSheet.show({
title: 'ActionSheet title', title: 'ActionSheet title',
message: 'message', message: 'message',
autoCancel: true,
confirm: { confirm: {
value: 'Confirm button', value: 'Confirm button',
action: () => { action: () => {
console.log('Get Alert Dialog handled'); console.log('Get Alert Dialog handled')
} }
}, },
cancel: () => {
console.log('actionSheet canceled')
},
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -10 },
sheets: [ sheets: [
{ {
title: 'apples', title: 'apples',
action: () => { action: () => {
console.log('apples'); console.log('apples')
} }
}, },
{ {
title: 'bananas', title: 'bananas',
action: () => { action: () => {
console.log('bananas'); console.log('bananas')
} }
}, },
{ {
title: 'pears', title: 'pears',
action: () => { action: () => {
console.log('pears'); console.log('pears')
} }
} }
] ]
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
| 名称 | 参数类型 | 参数描述 | | 名称 | 参数类型 | 参数描述 |
| ---- | --------------- | -------- | | ---- | --------------- | -------- |
| show | AlertDialogParamWithConfirm&nbsp;\|&nbsp;AlertDialogParamWithButtons | 定义并显示AlertDialog组件。 | | show | [AlertDialogParamWithConfirm](#alertdialogparamwithconfirm对象说明)&nbsp;\|&nbsp;[AlertDialogParamWithButtons](#alertdialogparamwithbuttons对象说明) | 定义并显示AlertDialog组件。 |
## AlertDialogParamWithConfirm对象说明 ## AlertDialogParamWithConfirm对象说明
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
| title | [ResourceStr](ts-types.md#resourcestr) | 否 | 弹窗标题。 | | title | [ResourceStr](ts-types.md#resourcestr) | 否 | 弹窗标题。 |
| message | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗内容。 | | message | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗内容。 |
| autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true | | autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true |
| confirm | {<br/>value:&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>fontColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>backgroundColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 确认按钮的文本内容、文本色、按钮背景色和点击回调。 | | confirm | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>fontColor?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>backgroundColor?:&nbsp;&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 确认按钮的文本内容、文本色、按钮背景色和点击回调。 |
| cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 | | cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 |
| alignment | [DialogAlignment](#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default | | alignment | [DialogAlignment](#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default |
| offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 | | offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 |
| gridCount | number | 否 | 弹窗容器宽度所占用栅格数。<br/>**说明:**<br/>当gridCount小于等于0时,弹窗宽度是固定的;大于0时,按照设置的数值显示宽度,最大值为4,若值为小数,则向下取整。 | | gridCount | number | 否 | 弹窗容器宽度所占用栅格数。 |
## AlertDialogParamWithButtons对象说明 ## AlertDialogParamWithButtons对象说明
| 参数名 | 参数类型 | 必填 | 参数描述 | | 参数名 | 参数类型 | 必填 | 参数描述 |
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
| title | [ResourceStr](ts-types.md#resourcestr) | 否 | 弹窗标题。 | | title | [ResourceStr](ts-types.md#resourcestr) | 否 | 弹窗标题。 |
| message | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗内容。 | | message | [ResourceStr](ts-types.md#resourcestr) | 是 | 弹窗内容。 |
| autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true | | autoCancel | boolean | 否 | 点击遮障层时,是否关闭弹窗。<br>默认值:true |
| primaryButton | {<br/>value:&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>fontColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>backgroundColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void;<br/>} | 否 | 按钮的文本内容、文本色、按钮背景色和点击回调。 | | primaryButton | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>fontColor?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>backgroundColor?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void;<br/>} | 否 | 按钮的文本内容、文本色、按钮背景色和点击回调。 |
| secondaryButton | {<br/>value:&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>fontColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>backgroundColor?:&nbsp;Color&nbsp;\|&nbsp;number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void;<br/>} | 否 | 按钮的文本内容、文本色、按钮背景色和点击回调。 | | secondaryButton | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>fontColor?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>backgroundColor?:&nbsp;[ResourceColor](ts-types.md#resourcecolor),<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void;<br/>} | 否 | 按钮的文本内容、文本色、按钮背景色和点击回调。 |
| cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 | | cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层关闭dialog时的回调。 |
| alignment | [DialogAlignment](#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default | | alignment | [DialogAlignment](#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default |
| offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 | | offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 |
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
@Entry @Entry
@Component @Component
struct AlertDialogExample { struct AlertDialogExample {
build() { build() {
Column({ space: 5 }) { Column({ space: 5 }) {
Button('one button dialog') Button('one button dialog')
...@@ -69,6 +68,10 @@ struct AlertDialogExample { ...@@ -69,6 +68,10 @@ struct AlertDialogExample {
{ {
title: 'title', title: 'title',
message: 'text', message: 'text',
autoCancel: true,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -20 },
gridCount: 3,
confirm: { confirm: {
value: 'button', value: 'button',
action: () => { action: () => {
...@@ -88,6 +91,10 @@ struct AlertDialogExample { ...@@ -88,6 +91,10 @@ struct AlertDialogExample {
{ {
title: 'title', title: 'title',
message: 'text', message: 'text',
autoCancel: true,
alignment: DialogAlignment.Bottom,
gridCount: 4,
offset: { dx: 0, dy: -20 },
primaryButton: { primaryButton: {
value: 'cancel', value: 'cancel',
action: () => { action: () => {
......
...@@ -22,25 +22,10 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut ...@@ -22,25 +22,10 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层退出时的回调。 | | cancel | ()&nbsp;=&gt;&nbsp;void | 否 | 点击遮障层退出时的回调。 |
| autoCancel | boolean | 否 | 是否允许点击遮障层退出。<br>默认值:true | | autoCancel | boolean | 否 | 是否允许点击遮障层退出。<br>默认值:true |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default | | alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment枚举说明) | 否 | 弹窗在竖直方向上的对齐方式。<br>默认值:DialogAlignment.Default |
| offset | {<br/>dx:&nbsp;Length&nbsp;\|&nbsp;[Resource](ts-types.md#resource),<br/>dy:&nbsp;Length&nbsp;&nbsp;\|&nbsp;[Resource](ts-types.md#resource)<br/>} | 否 | 弹窗相对alignment所在位置的偏移量。 | | offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 |
| customStyle | boolean | 否 | 弹窗容器样式是否自定义。<br>默认值:false | | customStyle | boolean | 否 | 弹窗容器样式是否自定义。<br>默认值:false |
| gridCount<sup>8+</sup> | number | 否 | 弹窗宽度占[栅格宽度](../../ui/ui-ts-layout-grid-container-new.md)的个数。 | | gridCount<sup>8+</sup> | number | 否 | 弹窗宽度占[栅格宽度](../../ui/ui-ts-layout-grid-container-new.md)的个数。 |
## DialogAlignment枚举说明
| 名称 | 描述 |
| ------------------------ | ------------------------------------------------------ |
| Top | 垂直顶部对齐。 |
| Center | 垂直居中对齐。 |
| Bottom | 垂直底部对齐。 |
| Default | 默认对齐。<br/>**说明:**<br/>与枚举值Center效果相同。 |
| TopStart<sup>8+</sup> | 左上对齐。 |
| TopEnd<sup>8+</sup> | 右上对齐。 |
| CenterStart<sup>8+</sup> | 左中对齐。 |
| CenterEnd<sup>8+</sup> | 右中对齐。 |
| BottomStart<sup>8+</sup> | 左下对齐。 |
| BottomEnd<sup>8+</sup> | 右下对齐。 |
## CustomDialogController ## CustomDialogController
...@@ -107,17 +92,28 @@ struct CustomDialogUser { ...@@ -107,17 +92,28 @@ struct CustomDialogUser {
@State textValue: string = '' @State textValue: string = ''
@State inputValue: string = 'click me' @State inputValue: string = 'click me'
dialogController: CustomDialogController = new CustomDialogController({ dialogController: CustomDialogController = new CustomDialogController({
builder: CustomDialogExample({ cancel: this.onCancel, confirm: this.onAccept, textValue: $textValue, inputValue: $inputValue }), builder: CustomDialogExample({
cancel: this.onCancel,
confirm: this.onAccept,
textValue: $textValue,
inputValue: $inputValue
}),
cancel: this.existApp, cancel: this.existApp,
autoCancel: true autoCancel: true,
alignment: DialogAlignment.Default,
offset: { dx: 0, dy: -20 },
gridCount: 4,
customStyle: false
}) })
onCancel() { onCancel() {
console.info('Callback when the first button is clicked') console.info('Callback when the first button is clicked')
} }
onAccept() { onAccept() {
console.info('Callback when the second button is clicked') console.info('Callback when the second button is clicked')
} }
existApp() { existApp() {
console.info('Click the callback in the blank area') console.info('Click the callback in the blank area')
} }
......
...@@ -49,7 +49,7 @@ struct Index { ...@@ -49,7 +49,7 @@ struct Index {
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) .bindContextMenu(this.MenuBuilder, ResponseType.LongPress)
.onDragStart(()=>{ .onDragStart(()=>{
// 拖拽时关闭菜单 // 拖拽时关闭菜单
ContextMenu.close(); ContextMenu.close()
}) })
} }
.width('100%') .width('100%')
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
状态管理模块提供了应用程序的数据存储能力、持久化数据管理能力、Ability数据存储能力和应用程序需要的环境状态,其中Ability数据存储从API version9开始支持。 状态管理模块提供了应用程序的数据存储能力、持久化数据管理能力、Ability数据存储能力和应用程序需要的环境状态,其中Ability数据存储从API version9开始支持。
> 说明:本模块首批接口从API version 7开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。 > **说明:**
>
> 本模块首批接口从API version 7开始支持,后续版本的新增接口,采用上角标单独标记接口的起始版本。
## AppStorage ## AppStorage
...@@ -142,7 +144,7 @@ let simple = AppStorage.Get('simpleProp') ...@@ -142,7 +144,7 @@ let simple = AppStorage.Get('simpleProp')
### Set ### Set
Set<T>(propName: string, newValue: T): boolean Set\<T>(propName: string, newValue: T): boolean
对已保存的key值,替换其value值。 对已保存的key值,替换其value值。
...@@ -165,7 +167,7 @@ let simple = AppStorage.Set('simpleProp', 121); ...@@ -165,7 +167,7 @@ let simple = AppStorage.Set('simpleProp', 121);
### SetOrCreate ### SetOrCreate
SetOrCreate<T>(propName: string, newValue: T): void SetOrCreate\<T>(propName: string, newValue: T): void
创建或更新setOrCreate内部的值。 创建或更新setOrCreate内部的值。
...@@ -646,7 +648,7 @@ PersistentStorage.PersistProps([{'highScore', '0'},{'wightScore','1'}]) ...@@ -646,7 +648,7 @@ PersistentStorage.PersistProps([{'highScore', '0'},{'wightScore','1'}])
### Keys ### Keys
Keys(): Array<string> Keys(): Array\<string>
返回所有持久化属性的标记。 返回所有持久化属性的标记。
...@@ -654,7 +656,7 @@ Keys(): Array<string> ...@@ -654,7 +656,7 @@ Keys(): Array<string>
| 类型 | 描述 | | 类型 | 描述 |
| ------------- | -------------------------- | | ------------- | -------------------------- |
| Array<string> | 返回所有持久化属性的标记。 | | Array\<string> | 返回所有持久化属性的标记。 |
```ts ```ts
let simple = PersistentStorage.Keys() let simple = PersistentStorage.Keys()
...@@ -728,7 +730,7 @@ Environment.EnvProps([{'accessibilityEnabled', 'default'},{'accessibilityUnEnabl ...@@ -728,7 +730,7 @@ Environment.EnvProps([{'accessibilityEnabled', 'default'},{'accessibilityUnEnabl
### Keys ### Keys
Keys(): Array<string> Keys(): Array\<string>
返回关联的系统项。 返回关联的系统项。
...@@ -736,7 +738,7 @@ Keys(): Array<string> ...@@ -736,7 +738,7 @@ Keys(): Array<string>
| 类型 | 描述 | | 类型 | 描述 |
| ------------- | ---------------------- | | ------------- | ---------------------- |
| Array<string> | 返回关联的系统项数组。 | | Array\<string> | 返回关联的系统项数组。 |
```ts ```ts
let simple = Environment.Keys() let simple = Environment.Keys()
......
...@@ -59,3 +59,5 @@ struct TransitionExample { ...@@ -59,3 +59,5 @@ struct TransitionExample {
} }
} }
``` ```
![animateTo](figures/animateTo.gif)
\ No newline at end of file
...@@ -53,3 +53,4 @@ struct pageBExample { ...@@ -53,3 +53,4 @@ struct pageBExample {
} }
``` ```
![shared](figures/shared.gif)
\ No newline at end of file
...@@ -126,19 +126,19 @@ sendMouseEvent(event: MouseEvent): boolean ...@@ -126,19 +126,19 @@ sendMouseEvent(event: MouseEvent): boolean
```ts ```ts
// xxx.ets // xxx.ets
class Utils { class Utils {
static rect_left; static rect_left
static rect_top; static rect_top
static rect_right; static rect_right
static rect_bottom; static rect_bottom
static rect_value; static rect_value
//获取组件所占矩形区域坐标 //获取组件所占矩形区域坐标
static getComponentRect(key) { static getComponentRect(key) {
let strJson = getInspectorByKey(key); let strJson = getInspectorByKey(key)
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson)
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj))
let rectInfo = JSON.parse('[' + obj.$rect + ']') let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo); console.info("[getInspectorByKey] rectInfo is: " + rectInfo)
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
......
...@@ -105,4 +105,4 @@ struct FlexExample { ...@@ -105,4 +105,4 @@ struct FlexExample {
} }
``` ```
![flex](figures/flex.PNG)
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
| saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大;小于1时消色成分越大,饱和度越小。(百分比) | | saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大;小于1时消色成分越大,饱和度越小。(百分比) |
| contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图像越清晰醒目;小于1时,值越小对比度越低;当对比度为0时,图像变为全灰。(百分比) | | contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图像越清晰醒目;小于1时,值越小对比度越低;当对比度为0时,图像变为全灰。(百分比) |
| invert | number | 0 | 反转输入的图像。入参为图像反转的比例。值为1时完全反转。值为0则图像无变化。(百分比) | | invert | number | 0 | 反转输入的图像。入参为图像反转的比例。值为1时完全反转。值为0则图像无变化。(百分比) |
| colorBlend&nbsp;<sup>8+</sup> | [Color](ts-appendix-enums.md#color)&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 |
| sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例。值为1则完全是深褐色的,值为0图像无变化。&nbsp;(百分比) | | sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例。值为1则完全是深褐色的,值为0图像无变化。&nbsp;(百分比) |
| hueRotate | number&nbsp;\|&nbsp;string | '0deg' | 色相旋转效果,输入参数为旋转角度。 | | hueRotate | number&nbsp;\|&nbsp;string | '0deg' | 色相旋转效果,输入参数为旋转角度。 |
| colorBlend&nbsp;<sup>8+</sup> | [Color](ts-appendix-enums.md#color)&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 |
## 示例 ## 示例
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
@Entry @Entry
@Component @Component
struct AspectRatioExample { struct AspectRatioExample {
private children: string[] = ['1', '2', '3', '4', '5', '6']; private children: string[] = ['1', '2', '3', '4', '5', '6']
build() { build() {
Column({ space: 20 }) { Column({ space: 20 }) {
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
## 示例 ## 示例
#### 普通菜单 ### 示例1
普通菜单
```ts ```ts
// xxx.ets // xxx.ets
...@@ -58,58 +60,59 @@ struct MenuExample { ...@@ -58,58 +60,59 @@ struct MenuExample {
![zh-cn_image_0000001174582862](figures/zh-cn_image_0000001174582862.gif) ![zh-cn_image_0000001174582862](figures/zh-cn_image_0000001174582862.gif)
#### 自定义内容菜单 ### 示例2
```ts 自定义内容菜单
// xxx.ets
import router from '@system.router';
```ts
@Entry @Entry
@Component @Component
struct MenuExample { struct MenuExample {
@State listData: number[] = [0, 0, 0]
@Builder MenuBuilder() { @Builder MenuBuilder() {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Text('text1') ForEach(this.listData, (item, index) => {
.fontSize(20) Column() {
.width(100) Row() {
.height(50) Image($r("app.media.icon")).width(20).height(20).margin({ right: 5 })
.textAlign(TextAlign.Center) Text(`Menu${index + 1}`).fontSize(20)
}
Divider().height(10) .width('100%')
.height(30)
Text('text2') .justifyContent(FlexAlign.Center)
.fontSize(20) .align(Alignment.Center)
.width(100)
.height(50)
.textAlign(TextAlign.Center)
Divider().height(10)
Button('Next')
.fontSize(20)
.width(100)
.height(50)
.onClick(() => { .onClick(() => {
router.push({ uri: 'pages/details' }) console.info(`Menu${index + 1} Clicked!`)
}) })
if (index != this.listData.length - 1) {
Divider().height(10).width('80%').color('#ccc')
}
}.padding(5).height(40)
})
}.width(100) }.width(100)
} }
build() { build() {
Column() { Column() {
Text('click for menu') Text('click for menu')
.fontSize(20)
.margin({ top: 20 })
.bindMenu(this.MenuBuilder)
} }
.height('100%')
.width('100%') .width('100%')
.margin({ top: 5 }) .backgroundColor('#f0f0f0')
.bindMenu(this.MenuBuilder)
} }
} }
``` ```
![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif) ![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif)
#### 菜单(右键触发显示) ### 示例3
菜单(右键触发显示)
```ts ```ts
// xxx.ets // xxx.ets
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
| primaryButton | {<br/>value:&nbsp;string,<br/>action:&nbsp;()&nbsp;=&gt;&nbsp;void<br/>} | 否 | 第一个按钮。<br/>value:&nbsp;弹窗里主按钮的文本。<br/>action:&nbsp;点击主按钮的回调函数。 | | 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;点击辅助按钮的回调函数。 | | 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为弹窗当前的显示状态。 | | onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 |
| arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| showInSubWindow<sup>9+</sup> | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 |
## CustomPopupOptions<sup>8+</sup>类型说明 ## CustomPopupOptions<sup>8+</sup>类型说明
...@@ -39,6 +41,8 @@ ...@@ -39,6 +41,8 @@
| enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。<br/>默认值:true | | enableArrow | boolean | 否 | 是否显示箭头。<br/>从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。<br/>默认值:true |
| autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡。<br/>默认值:true | | autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡。<br/>默认值:true |
| onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | | onStateChange | (event:&nbsp;{&nbsp;isVisible:&nbsp;boolean&nbsp;})&nbsp;=&gt;&nbsp;void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 |
| arrowOffset<sup>9+</sup> | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 |
| showInSubWindow<sup>9+</sup> | boolean | 否 | 是否在子窗口显示气泡,默认值为false。 |
## 示例 ## 示例
...@@ -80,7 +84,7 @@ struct PopupExample { ...@@ -80,7 +84,7 @@ struct PopupExample {
secondaryButton: { secondaryButton: {
value: 'cancel', value: 'cancel',
action: () => { action: () => {
this.handlePopup = !this.handlePopup; this.handlePopup = !this.handlePopup
console.info('cancel Button click') console.info('cancel Button click')
} }
}, },
......
...@@ -53,3 +53,4 @@ struct ClipAndMaskExample { ...@@ -53,3 +53,4 @@ struct ClipAndMaskExample {
} }
``` ```
![clipAndMask](figures/clipAndMask.PNG)
\ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
@Entry @Entry
@Component @Component
struct TouchTargetExample { struct TouchTargetExample {
@State text: string = ""; @State text: string = ""
build() { build() {
Column({ space: 20 }) { Column({ space: 20 }) {
...@@ -49,7 +49,7 @@ struct TouchTargetExample { ...@@ -49,7 +49,7 @@ struct TouchTargetExample {
Button("button1") Button("button1")
.responseRegion({ x: 0, y: 0, width: '50%', height: '100%' }) .responseRegion({ x: 0, y: 0, width: '50%', height: '100%' })
.onClick(() => { .onClick(() => {
this.text = 'button1 clicked'; this.text = 'button1 clicked'
}) })
// 热区宽度为按钮的一半,且右移一个按钮宽度,点击button2右侧左边,点击事件生效 // 热区宽度为按钮的一半,且右移一个按钮宽度,点击button2右侧左边,点击事件生效
...@@ -57,14 +57,14 @@ struct TouchTargetExample { ...@@ -57,14 +57,14 @@ struct TouchTargetExample {
Button("button2") Button("button2")
.responseRegion({ x: '100%', y: 0, width: '50%', height: '100%' }) .responseRegion({ x: '100%', y: 0, width: '50%', height: '100%' })
.onClick(() => { .onClick(() => {
this.text = 'button2 clicked'; this.text = 'button2 clicked'
}) })
// 热区大小为整个按钮,且下移一个按钮高度,点击button3下方按钮大小区域,点击事件生效 // 热区大小为整个按钮,且下移一个按钮高度,点击button3下方按钮大小区域,点击事件生效
Text("{x:0,y:'100%',width:'100%',height:'100%'}") Text("{x:0,y:'100%',width:'100%',height:'100%'}")
Button("button3") Button("button3")
.responseRegion({ x: 0, y: '100%', width: '100%', height: '100%' }) .responseRegion({ x: 0, y: '100%', width: '100%', height: '100%' })
.onClick(() => { .onClick(() => {
this.text = 'button3 clicked'; this.text = 'button3 clicked'
}) })
Text(this.text).margin({ top: 50 }) Text(this.text).margin({ top: 50 })
......
...@@ -14,21 +14,21 @@ ...@@ -14,21 +14,21 @@
| rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;Angle,<br/>centerX?:&nbsp;number \| string,<br/>centerY?:&nbsp;number \| string<br/>} | (x,&nbsp;y,&nbsp;z)指定一个矢量,表示旋转轴,正角度为顺时针转动,负角度为逆时针转动,默认值为0,同时可以通过centerX和centerY设置旋转的中心点。<br>默认值:<br>{<br/>x:&nbsp;0,<br/>y:&nbsp;0,<br/>z:&nbsp;0,<br/>angle:&nbsp;0,<br/>centerX:&nbsp;'50%',<br/>centerY:&nbsp;'50%'<br/>} | | rotate | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>angle?:&nbsp;Angle,<br/>centerX?:&nbsp;number \| string,<br/>centerY?:&nbsp;number \| string<br/>} | (x,&nbsp;y,&nbsp;z)指定一个矢量,表示旋转轴,正角度为顺时针转动,负角度为逆时针转动,默认值为0,同时可以通过centerX和centerY设置旋转的中心点。<br>默认值:<br>{<br/>x:&nbsp;0,<br/>y:&nbsp;0,<br/>z:&nbsp;0,<br/>angle:&nbsp;0,<br/>centerX:&nbsp;'50%',<br/>centerY:&nbsp;'50%'<br/>} |
| translate | {<br/>x?:&nbsp;number \| string,<br/>y?:&nbsp;number \| string,<br/>z?&nbsp;:&nbsp;number \| string<br/>} | 可以分别设置X轴、Y轴、Z轴的平移距离,距离的正负控制平移的方向。不支持百分比形式的输入。<br>默认值:<br>{<br/>x:&nbsp;0,<br/>y:&nbsp;0,<br/>z:&nbsp;0<br/>}| | translate | {<br/>x?:&nbsp;number \| string,<br/>y?:&nbsp;number \| string,<br/>z?&nbsp;:&nbsp;number \| string<br/>} | 可以分别设置X轴、Y轴、Z轴的平移距离,距离的正负控制平移的方向。不支持百分比形式的输入。<br>默认值:<br>{<br/>x:&nbsp;0,<br/>y:&nbsp;0,<br/>z:&nbsp;0<br/>}|
| scale | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>centerX?:&nbsp;number \| string,<br/>centerY?:&nbsp;number \| string<br/>} | 可以分别设置X轴、Y轴、Z轴的缩放比例,默认值为1,同时可以通过centerX和centerY设置缩放的中心点。<br>默认值:<br>{<br/>x:&nbsp;1,<br/>y:&nbsp;1,<br/>z:&nbsp;1,<br/>centerX:'50%',<br/>centerY:'50%'<br/>} | | scale | {<br/>x?:&nbsp;number,<br/>y?:&nbsp;number,<br/>z?:&nbsp;number,<br/>centerX?:&nbsp;number \| string,<br/>centerY?:&nbsp;number \| string<br/>} | 可以分别设置X轴、Y轴、Z轴的缩放比例,默认值为1,同时可以通过centerX和centerY设置缩放的中心点。<br>默认值:<br>{<br/>x:&nbsp;1,<br/>y:&nbsp;1,<br/>z:&nbsp;1,<br/>centerX:'50%',<br/>centerY:'50%'<br/>} |
| transform | Matrix4Transit | 设置当前组件的变换矩阵。 | | transform | [Matrix4Transit](../apis/js-apis-matrix4.md) | 设置当前组件的变换矩阵。 |
## 示例 ## 示例
```ts ```ts
// xxx.ets // xxx.ets
import Matrix4 from '@ohos.matrix4' import matrix4 from '@ohos.matrix4'
@Entry @Entry
@Component @Component
struct TransformExample { struct TransformExample {
build() { build() {
Column() { Column() {
Text('rotate').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(30) Text('rotate').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14)
Row() Row()
.rotate({ .rotate({
x: 1, x: 1,
...@@ -37,26 +37,29 @@ struct TransformExample { ...@@ -37,26 +37,29 @@ struct TransformExample {
centerX: '50%', centerX: '50%',
centerY: '50%', centerY: '50%',
angle: 300 angle: 300
}) // 组件以(1,1,1)为旋转轴,中心点顺时针旋转 300度 }) // 组件以矢量(1,1,1)为旋转轴,绕中心点顺时针旋转300度
.width(100).height(100).backgroundColor(0xAFEEEE) .width(100).height(100).backgroundColor(0xAFEEEE)
Text('translate').width('90%').fontColor(0xCCCCCC).padding(10).fontSize(30) Text('translate').width('90%').fontColor(0xCCCCCC).padding(10).fontSize(14)
Row() Row()
.translate({ x: 100, y: 5 }) // x轴平移100,y轴平移5 .translate({ x: 100, y: 10 }) // x轴方向平移100,y轴方向平移10
.width(100).height(100).backgroundColor(0xAFEEEE).margin({bottom:10}) .width(100).height(100).backgroundColor(0xAFEEEE).margin({ bottom: 10 })
Text('scale').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(30) Text('scale').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14)
Row() Row()
.scale({ x: 2, y: 0.5 }) // 高度缩小一倍,宽度放大一倍,z轴在2D下无效果 .scale({ x: 2, y: 0.5 }) // 高度缩小一倍,宽度放大一倍,z轴在2D下无效果
.width(100).height(100).backgroundColor(0xAFEEEE) .width(100).height(100).backgroundColor(0xAFEEEE)
Text('Matrix4').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(30) Text('Matrix4').width('90%').fontColor(0xCCCCCC).padding(15).fontSize(14)
Row() Row()
.width(100).height(100).backgroundColor(0xAFEEEE) .width(100).height(100).backgroundColor(0xAFEEEE)
.transform(Matrix4.identity().translate({ x: 100, y: 100, z: 30 })) .transform(matrix4.identity().translate({ x: 50, y: 50 }).scale({ x: 1.5, y: 1 }).rotate({
x: 0,
y: 0,
z: 1,
angle: 60
}))
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
} }
} }
``` ```
![zh-cn_image_0000001219864137](figures/zh-cn_image_0000001219864137.png)
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
@Entry @Entry
@Component @Component
struct FocusEventExample { struct FocusEventExample {
@State oneButtonColor: string = '#FFC0CB'; @State oneButtonColor: string = '#FFC0CB'
@State twoButtonColor: string = '#87CEFA'; @State twoButtonColor: string = '#87CEFA'
@State threeButtonColor: string = '#90EE90'; @State threeButtonColor: string = '#90EE90'
build() { build() {
Column({ space: 20 }) { Column({ space: 20 }) {
...@@ -38,10 +38,10 @@ struct FocusEventExample { ...@@ -38,10 +38,10 @@ struct FocusEventExample {
.fontColor(Color.Black) .fontColor(Color.Black)
.focusable(true) .focusable(true)
.onFocus(() => { .onFocus(() => {
this.oneButtonColor = '#FF0000'; this.oneButtonColor = '#FF0000'
}) })
.onBlur(() => { .onBlur(() => {
this.oneButtonColor = '#FFC0CB'; this.oneButtonColor = '#FFC0CB'
}) })
Button('Second Button') Button('Second Button')
.backgroundColor(this.twoButtonColor) .backgroundColor(this.twoButtonColor)
...@@ -50,10 +50,10 @@ struct FocusEventExample { ...@@ -50,10 +50,10 @@ struct FocusEventExample {
.fontColor(Color.Black) .fontColor(Color.Black)
.focusable(true) .focusable(true)
.onFocus(() => { .onFocus(() => {
this.twoButtonColor = '#FF0000'; this.twoButtonColor = '#FF0000'
}) })
.onBlur(() => { .onBlur(() => {
this.twoButtonColor = '#87CEFA'; this.twoButtonColor = '#87CEFA'
}) })
Button('Third Button') Button('Third Button')
.backgroundColor(this.threeButtonColor) .backgroundColor(this.threeButtonColor)
...@@ -62,10 +62,10 @@ struct FocusEventExample { ...@@ -62,10 +62,10 @@ struct FocusEventExample {
.fontColor(Color.Black) .fontColor(Color.Black)
.focusable(true) .focusable(true)
.onFocus(() => { .onFocus(() => {
this.threeButtonColor = '#FF0000'; this.threeButtonColor = '#FF0000'
}) })
.onBlur(() => { .onBlur(() => {
this.threeButtonColor = '#90EE90'; this.threeButtonColor = '#90EE90'
}) })
}.width('100%').margin({ top: 20 }) }.width('100%').margin({ top: 20 })
} }
......
# DistributedSchedule错误码 # DistributedSchedule错误码
## 201 权限校验失败
### 错误信息
Permission denied.
### 错误描述
当调用流转管理和迁移等接口时,若缺少ohos.permission.MANAGER_MISSIONS或ohos.permission.DISTRIBUTED_DATASYNC,会报此错误码。
### 可能原因
该错误码表示权限校验失败,可能原因是未配置对应权限。
### 处理步骤
配置权限ohos.permission.MANAGER_MISSIONS或ohos.permission.DISTRIBUTED_DATASYNC。
## 401 参数检查错误
### 错误信息
The parameter check failed.
### 错误描述
当调用接口提供的入参出现类型、个数、数组大小以及合法性等错误时,会报此错误码。
### 可能原因
该错误码表示入参检查错误,可能原因是callback入参检查错误。
### 处理步骤
检查入参callback是否为合法值。
## 16600001 系统服务工作异常 ## 16600001 系统服务工作异常
### 错误信息 **错误信息**
The system ability work abnormally.
The system ability works abnormally.
### 错误描述 **错误描述**
当系统服务工作异常时,会报此错误码。 当系统服务工作异常时,会报此错误码。
### 可能原因 **可能原因**
该错误码表示系统服务工作异常,可能原因如下。 该错误码表示系统服务工作异常,可能原因如下。
1. DMS服务没有正常启动。 1. DMS服务没有正常启动。
2. DMS的binder对象无法正常获取。 2. DMS的binder对象无法正常获取。
3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。 3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤 **处理步骤**
系统服务内部工作异常,请稍后重试,或者重启设备尝试。 系统服务内部工作异常,请稍后重试,或者重启设备尝试。
## 16600002 指定的token或callback未注册 ## 16600002 指定的token或callback未注册
### 错误描述 **错误描述**
当调用continuationManager相关的接口时传入的token或callback未提前注册,会报此错误码。 当调用continuationManager相关的接口时传入的token或callback未提前注册,会报此错误码。
### 错误信息 **错误信息**
The specified token or callback has not registered.
The specified token or callback is not registered.
**可能原因**
### 可能原因
该错误码可能原因是指定的token或callback未注册。 该错误码可能原因是指定的token或callback未注册。
### 处理步骤 **处理步骤**
请先注册token或callback。 请先注册token或callback。
## 16600003 应用注册token已达到最大次数限制 ## 16600003 应用注册token已达到最大次数限制
### 错误描述 **错误描述**
当调用continuationManager.registerContinuation接口时次数过多超出限制,会报此错误码。 当调用continuationManager.registerContinuation接口时次数过多超出限制,会报此错误码。
### 错误信息 **错误信息**
The number of token registration times has reached the upper limit. The number of token registration times has reached the upper limit.
### 可能原因 **可能原因**
该错误码可能原因是应用注册token已达到最大次数限制。 该错误码可能原因是应用注册token已达到最大次数限制。
### 处理步骤 **处理步骤**
请勿频繁注册,请使用已注册的token。 请勿频繁注册,请使用已注册的token。
## 16600004 指定的callback已注册 ## 16600004 指定的callback已注册
### 错误描述 **错误描述**
当使用相同的callback调用continuationManager的on接口时,会报此错误码。 当使用相同的callback调用continuationManager的on接口时,会报此错误码。
### 错误信息 **错误信息**
The specified callback has been registered. The specified callback has been registered.
### 可能原因 **可能原因**
该错误码表示指定的callback已注册,可能原因是使用相同的callback重复注册。 该错误码表示指定的callback已注册,可能原因是使用相同的callback重复注册。
### 处理步骤 **处理步骤**
请勿使用相同的callback重复注册。 请勿使用相同的callback重复注册。
## 16300501 系统服务工作异常 ## 16300501 系统服务工作异常
### 错误描述 **错误描述**
当系统服务工作异常时,会报此错误码。 当系统服务工作异常时,会报此错误码。
### 错误信息 **错误信息**
The system ability work abnormally.
The system ability works abnormally.
**可能原因**
### 可能原因
该错误码表示系统服务工作异常,可能原因如下。 该错误码表示系统服务工作异常,可能原因如下。
1. DMS服务没有正常启动。 1. DMS服务没有正常启动。
2. DMS的binder对象无法正常获取。 2. DMS的binder对象无法正常获取。
3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。 3. 流转依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤 **处理步骤**
系统服务内部工作异常,请稍后重试,或者重启设备尝试。 系统服务内部工作异常,请稍后重试,或者重启设备尝试。
## 16300502 获取指定的missionId的missionInfo失败 ## 16300502 获取指定的missionId的missionInfo失败
### 错误描述 **错误描述**
当调用distributedMissionManager.continueMission接口获取指定missionId的missionInfo失败时,会报此错误码。 当调用distributedMissionManager.continueMission接口获取指定missionId的missionInfo失败时,会报此错误码。
### 错误信息 **错误信息**
Failed to get the missionInfo of the specified missionId. Failed to get the missionInfo of the specified missionId.
### 可能原因 **可能原因**
该错误码表示获取指定的missionId的missionInfo失败,可能原因如下。 该错误码表示获取指定的missionId的missionInfo失败,可能原因如下。
1. missionId输入错误。 1. missionId输入错误。
2. missionId对应的missionInfo确实不存在。 2. missionId对应的missionInfo确实不存在。
### 处理步骤 **处理步骤**
请检查输入的missionId是否正确。 请检查输入的missionId是否正确。
## 16300503 远端未安装应用且不支持免安装 ## 16300503 远端未安装应用且不支持免安装
### 错误描述 **错误描述**
当调用distributedMissionManager.continueMission接口使用迁移功能时,若远端未安装应用且不支持免安装,会报此错误码。 当调用distributedMissionManager.continueMission接口使用迁移功能时,若远端未安装应用且不支持免安装,会报此错误码。
### 错误信息 **错误信息**
The application is not installed on the remote end and installation-free is not supported. The application is not installed on the remote end and installation-free is not supported.
### 可能原因 **可能原因**
该错误码可能原因是远端未安装迁移应用并且不支持免安装。 该错误码可能原因是远端未安装迁移应用并且不支持免安装。
### 处理步骤 **处理步骤**
1. 请检查远端是否已安装需要迁移的应用。 1. 请检查远端是否已安装需要迁移的应用。
2. 请检查远端是否支持免安装。 2. 请检查远端是否支持免安装。
## 16300504 远端未安装应用但支持免安装,需使用免安装标识重试 ## 16300504 远端未安装应用但支持免安装,需使用免安装标识重试
### 错误描述 **错误描述**
当调用distributedMissionManager.continueMission接口使用迁移功能时,若远端未安装应用但支持免安装,会报此错误码。 当调用distributedMissionManager.continueMission接口使用迁移功能时,若远端未安装应用但支持免安装,会报此错误码。
### 错误信息 **错误信息**
The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag.
The application is not installed on the remote end and installation-free is supported. Try again with the freeInstall flag.
**可能原因**
### 可能原因
该错误码可能原因是远端未安装应用但支持免安装,使用时未使用免安装的标识。 该错误码可能原因是远端未安装应用但支持免安装,使用时未使用免安装的标识。
### 处理步骤 **处理步骤**
请使用免安装的标识重试。 请使用免安装的标识重试。
## 16300505 操作设备必须是迁移的应用所在的设备或需迁移到的目标设备 ## 16300505 操作设备必须是迁移的应用所在的设备或需迁移到的目标设备
### 错误描述 **错误描述**
当调用distributedMissionManager.continueMission接口使用迁移功能时,若操作设备不是迁移的应用所在的设备或需迁移到的目标设备,会报此错误码。 当调用distributedMissionManager.continueMission接口使用迁移功能时,若操作设备不是迁移的应用所在的设备或需迁移到的目标设备,会报此错误码。
### 错误信息 **错误信息**
The operation device must be the device where the application to be continued is located or the target device to be continued.
The operation device must be the device where the application to be continued is currently located or the target device.
**可能原因**
### 可能原因
该错误码可能原因是操作设备不是迁移的应用所在的设备或需迁移到的目标设备。 该错误码可能原因是操作设备不是迁移的应用所在的设备或需迁移到的目标设备。
### 处理步骤 **处理步骤**
请检查操作设备是否是迁移的应用所在的设备或需迁移到的目标设备。 请检查操作设备是否是迁移的应用所在的设备或需迁移到的目标设备。
## 16300506 本地迁移任务已在进行中 ## 16300506 本地迁移任务已在进行中
### 错误描述 **错误描述**
当调用distributedMissionManager.continueMission接口使用迁移功能时,若本地迁移任务已在进行中,会报此错误码。 当调用distributedMissionManager.continueMission接口使用迁移功能时,若本地迁移任务已在进行中,会报此错误码。
### 错误信息 **错误信息**
The local continuation task is already in progress. The local continuation task is already in progress.
### 可能原因 **可能原因**
该错误码表示本地迁移任务已在进行中,可能原因是已经发起了迁移任务还未结束。 该错误码表示本地迁移任务已在进行中,可能原因是已经发起了迁移任务还未结束。
### 处理步骤 **处理步骤**
请检查是否已经发起了迁移并未结束。 请检查是否已经发起了迁移并未结束。
## 3 序列化对象失败 ## 3 序列化对象失败
### 错误描述 **错误描述**
当调用continuationManager相关接口时,若系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败,会报此错误码。 当调用continuationManager相关接口时,若系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败,会报此错误码。
### 错误信息 **错误信息**
Failed to flatten the object. Failed to flatten the object.
### 可能原因 **可能原因**
该错误码表示对象序列化过程中出现错误,可能原因是系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败。 该错误码表示对象序列化过程中出现错误,可能原因是系统参数DMS_PROXY_INTERFACE_TOKEN序列化写失败。
### 处理步骤 **处理步骤**
请检查系统功能是否正常或者重启。 请检查系统功能是否正常或者重启。
## 7 空对象 ## 7 空对象
### 错误信息 **错误信息**
The object is null. The object is null.
### 错误描述 **错误描述**
当调用流转和迁移相关接口时,若出现dms以及其他对象为空或序列化读失败,会报此错误码。 当调用流转和迁移相关接口时,若出现dms以及其他对象为空或序列化读失败,会报此错误码。
### 可能原因 **可能原因**
该错误码表示接口依赖的服务对象或参数对象为空,可能原因如下。 该错误码表示接口依赖的服务对象或参数对象为空,可能原因如下。
1. 入参序列化读失败。 1. 入参序列化读失败。
2. DMS服务没有正常启动或binder对象无法正常获取。 2. DMS服务没有正常启动或binder对象无法正常获取。
3. DMS依赖的其他服务没有正常启动或者binder对象无法获取。 3. DMS依赖的其他服务没有正常启动或者binder对象无法获取。
### 处理步骤 **处理步骤**
1. 检查入参是否为有效合法值。 1. 检查入参是否为有效合法值。
2. 检查DMS服务是否正常启动,重新启动服务或重启设备。 2. 检查DMS服务是否正常启动,重新启动服务或重启设备。
3. 检查DMS依赖的其他服务是否正常启动,重新启动服务或重启设备。 3. 检查DMS依赖的其他服务是否正常启动,重新启动服务或重启设备。
## 29360207 注册超出最大次数 ## 29360207 注册超出最大次数
### 错误描述 **错误描述**
当调用continuationManager.register接口时次数过多超出限制,会报此错误码。 当调用continuationManager.register接口时次数过多超出限制,会报此错误码。
### 错误信息 **错误信息**
The maximum number of registrations exceeded.
The number of registrations has reached the upper limit.
**可能原因**
### 可能原因
该错误码可能原因是设备频繁注册,次数超出最大次数限制。 该错误码可能原因是设备频繁注册,次数超出最大次数限制。
### 处理步骤 **处理步骤**
重启服务并且避免频繁注册。 重启服务并且避免频繁注册。
## 29360208 token未注册 ## 29360208 token未注册
### 错误描述 **错误描述**
当调用continuationManager相关接口时使用未注册的token,会报此错误码。 当调用continuationManager相关接口时使用未注册的token,会报此错误码。
### 错误信息 **错误信息**
The token has not registered.
The token is not registered.
**可能原因**
### 可能原因
该错误码可能原因是未注册token。 该错误码可能原因是未注册token。
### 处理步骤 **处理步骤**
注册token并使用已注册的token。 注册token并使用已注册的token。
## 29360209 callback已注册 ## 29360209 callback已注册
### 错误描述 **错误描述**
当使用相同的callback重复调用continuationManager.on接口时,会报此错误码。 当使用相同的callback重复调用continuationManager.on接口时,会报此错误码。
### 错误信息 **错误信息**
Callback has been registered.
The callback has been registered.
**可能原因**
### 可能原因
该错误码能原因是指定的callback已经注册过。 该错误码能原因是指定的callback已经注册过。
### 处理步骤 **处理步骤**
请勿使用相同的callback重复注册。 请勿使用相同的callback重复注册。
## 29360210 callback未注册 ## 29360210 callback未注册
### 错误描述 **错误描述**
当调用continuationManager的off、updateConnectStatus和startDeviceManager等接口时,若未提前调用on接口注册callback,会报此错误码。 当调用continuationManager的off、updateConnectStatus和startDeviceManager等接口时,若未提前调用on接口注册callback,会报此错误码。
### 错误信息 **错误信息**
Callback has not been registered.
The callback is not registered.
**可能原因**
### 可能原因
该错误码可能原因是指定的callback未注册。 该错误码可能原因是指定的callback未注册。
### 处理步骤 **处理步骤**
注册callback并使用已注册的callback。 注册callback并使用已注册的callback。
## 29360211 连接ability失败 ## 29360211 连接ability失败
### 错误描述 **错误描述**
当调用continuationManager的startDeviceManager接口时,若连接相应Ability失败时,会报此错误码。 当调用continuationManager的startDeviceManager接口时,若连接相应Ability失败时,会报此错误码。
### 错误信息 **错误信息**
Failed to connect ability.
Failed to connect to the ability.
**可能原因**
### 可能原因
该错误码可能原因是指定token连接ability失败。 该错误码可能原因是指定token连接ability失败。
### 处理步骤 **处理步骤**
检查token是否有效以及相应ability是否正常服务,重新启动服务或重启设备。 检查token是否有效以及相应ability是否正常服务,重新启动服务或重启设备。
## 29360214 callback类型错误 ## 29360214 callback类型错误
### 错误描述 **错误描述**
当调用continuationManager的on和off接口时,若参数callback类型错误时,会报此错误码。 当调用continuationManager的on和off接口时,若参数callback类型错误时,会报此错误码。
### 错误信息 **错误信息**
The type of callback is not supported. The type of callback is not supported.
### 可能原因 **可能原因**
该错误码表示callback类型错误,可能原因是不支持传入的callback类型。 该错误码表示callback类型错误,可能原因是不支持传入的callback类型。
### 处理步骤 **处理步骤**
请使用系统支持的callback类型并传入。 请使用系统支持的callback类型并传入。
## 29360215 无效的连接状态 ## 29360215 无效的连接状态
### 错误描述 **错误描述**
当调用continuationManager的updateConnectStatus接口时,若参数status为无效值时,会报此错误码。 当调用continuationManager的updateConnectStatus接口时,若参数status为无效值时,会报此错误码。
### 错误信息 **错误信息**
Invalid connect state.
Invalid connection state.
**可能原因**
### 可能原因
该错误码表示无效的连接状态,可能原因是入参DeviceConnectState为非指定值。 该错误码表示无效的连接状态,可能原因是入参DeviceConnectState为非指定值。
### 处理步骤 **处理步骤**
设置指定合法的DeviceConnectState值。 设置指定合法的DeviceConnectState值。
## 29360216 无效的流转模式 ## 29360216 无效的流转模式
### 错误描述 **错误信息**
Invalid continuation mode.
**错误描述**
当调用continuationManager的register和startDeviceManager接口时,若参数ContinuationExtraParams.continuationMode为无效值时,会报此错误码。 当调用continuationManager的register和startDeviceManager接口时,若参数ContinuationExtraParams.continuationMode为无效值时,会报此错误码。
### 错误信息 **可能原因**
Invalid continuation mode.
### 可能原因
该错误码可能原因是入参ContinuationExtraParams.continuationMode为非指定值。 该错误码可能原因是入参ContinuationExtraParams.continuationMode为非指定值。
### 处理步骤 **处理步骤**
设置指定合法的ContinuationExtraParams.continuationMode值。 设置指定合法的ContinuationExtraParams.continuationMode值。
...@@ -100,21 +100,17 @@ function testGenerateAesKey() { ...@@ -100,21 +100,17 @@ function testGenerateAesKey() {
示例3:根据指定的RSA非对称密钥二进制数据,生成KeyPair对象(场景2) 示例3:根据指定的RSA非对称密钥二进制数据,生成KeyPair对象(场景2)
1. 获取RSA二进制密钥数据封装成DataBlob对象,按keysize(32位的密钥位数) 、nsize(32位,值为keysize/8)、 esize(32位的大数e的实际长度,单位Byte)、dsize(32位,值位keysize/8)、nval(大数n的二进制数据)、eval(大数e的二进制数据)和dval(大数d的二进制数据)拼接形成 1. 获取RSA公钥或私钥二进制数据,公钥需满足ASN.1语法、X.509规范、DER编码格式,私钥需满足ASN.1语法、PKCS#8规范、DER编码格式
2. 调用convertKey方法,传入公钥二进制和私钥二进制(二者非必选项,可只传入其中一个),转换为KeyPair对象。 2. 创建AsyKeyGenerator对象,调用convertKey方法,传入公钥二进制和私钥二进制(二者非必选项,可只传入其中一个),转换为KeyPair对象。
```javascript ```javascript
import cryptoFramework from '@ohos.security.cryptoFramework'; import cryptoFramework from '@ohos.security.cryptoFramework';
function convertAsyKey() { function convertAsyKey() {
let rsaGenerator = cryptoFramework.createAsyKeyGenerator("RSA1024"); let rsaGenerator = cfm.createAsyKeyGenerator("RSA1024");
// 公钥二进制数据 let pkval = new Uint8Array([48,129,159,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,129,141,0,48,129,137,2,129,129,0,174,203,113,83,113,3,143,213,194,79,91,9,51,142,87,45,97,65,136,24,166,35,5,179,42,47,212,79,111,74,134,120,73,67,21,19,235,80,46,152,209,133,232,87,192,140,18,206,27,106,106,169,106,46,135,111,118,32,129,27,89,255,183,116,247,38,12,7,238,77,151,167,6,102,153,126,66,28,253,253,216,64,20,138,117,72,15,216,178,37,208,179,63,204,39,94,244,170,48,190,21,11,73,169,156,104,193,3,17,100,28,60,50,92,235,218,57,73,119,19,101,164,192,161,197,106,105,73,2,3,1,0,1]);
let pkval = new Uint8Array([0,4,0,0,128,0,0,0,3,0,0,0,0,0,0,0,182,22,137,81,111,129,17,47,33,97,67,85,251,53,127,42,130,150,93,144,129,104,14,73,110,189,138,82,53,74,114,86,24,186,143,65,87,110,237,69,206,207,5,81,24,32,41,160,209,125,162,92,0,148,49,241,235,0,71,198,1,28,136,106,152,22,25,249,77,241,57,149,154,44,200,6,0,83,246,63,162,106,242,131,80,227,143,162,210,28,127,136,123,172,26,247,2,194,16,1,100,122,180,251,57,22,69,133,232,145,107,66,80,201,151,46,114,175,116,57,45,170,188,77,86,230,111,45,1,0,1]);
// 封装成DataBlob对象
let pkBlob = {data : pkval}; let pkBlob = {data : pkval};
// 调用密钥转换函数 rsaGenerator.convertKey(pkBlob, null, function(err, keyPair) {
let convertKeyPromise = rsaGenerator.convertKey(pkBlob, null);
convertKeyPromise.then( keyPair => {
if (keyPair == null) { if (keyPair == null) {
AlertDialog.show({message : "Convert keypair fail"}); AlertDialog.show({message : "Convert keypair fail"});
} }
...@@ -125,10 +121,7 @@ function convertAsyKey() { ...@@ -125,10 +121,7 @@ function convertAsyKey() {
**说明** **说明**
1. nsize和dsize为密钥位数/8,esize为具体的实际长度。 当前convertKey操作,公钥只支持转换满足X.509规范的DER格式,私钥只支持PKCS#8规范的DER格式;
2. 私钥材料需要包含keysize,nsize,esize,dsize,nval,eval,dval的全部数据,公钥材料中dsize设置为为0,缺省dval的数据。
3. 公钥和私钥二进制数据为可选项,可单独传入公钥或私钥的数据,生成对应只包含公钥或私钥的KeyPair对象。
4. keysize、nsize、esize和dsize为32位二进制数据,数据的大小端格式请按设备CPU默认格式,密钥材料(nval、eval、dval)统一为大端格式。
示例4:根据指定的ECC非对称密钥二进制数据,生成KeyPair对象(场景2、3) 示例4:根据指定的ECC非对称密钥二进制数据,生成KeyPair对象(场景2、3)
...@@ -545,6 +538,12 @@ function encryptMessageCallback() { ...@@ -545,6 +538,12 @@ function encryptMessageCallback() {
} }
``` ```
**说明**
1. 使用RSA加解密时,Cipher对象不可重复调用init方法初始化,在创建了一个加密Cipher对象后,如果要进行解密,则需要重新创建另一个Cipher对象执行解密操作。
2. RSA加密有长度限制,允许加密明文的最大长度见[加解密算法库框架概述](cryptoFramework-overview.md)中的基本概念章节。
3. RSA解密每次允许解密的密文长度为,RSA密钥的位数/8。
## 使用签名验签操作 ## 使用签名验签操作
**场景说明** **场景说明**
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
- [AudioDeviceDescriptor](_audio_device_descriptor.md) - [AudioDeviceDescriptor](_audio_device_descriptor.md)
- [AudioManager](_audio_manager.md) - [AudioManager](_audio_manager.md)
- [AudioMixExtInfo](_audio_mix_ext_info.md) - [AudioMixExtInfo](_audio_mix_ext_info.md)
- [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) - [AudioMmapBufferDescriptor](_audio_mmap_buffer_descriptor.md)
- [AudioPort](_audio_port.md) - [AudioPort](_audio_port.md)
- [AudioPortCap](audio_portcap.md) - [AudioPortCap](audio_portcap.md)
- [AudioPortCapability](_audio_port_capability.md) - [AudioPortCapability](_audio_port_capability.md)
......
...@@ -54,7 +54,7 @@ Audio模块接口定义。 ...@@ -54,7 +54,7 @@ Audio模块接口定义。
| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 | | [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 |
| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 | | [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 |
| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 | | [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 |
| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 | | [AudioMmapBufferDescriptor](_audio_mmap_buffer_descriptor.md) | mmap缓冲区描述符 |
| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息 | | [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息 |
| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 | | [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 |
| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 | | [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 |
...@@ -145,11 +145,11 @@ Audio模块接口定义。 ...@@ -145,11 +145,11 @@ Audio模块接口定义。
| [AudioPortCapability::subPorts](#subports) | 支持的子端口列表。 | | [AudioPortCapability::subPorts](#subports) | 支持的子端口列表。 |
| [AudioPortCapability::supportSampleFormatNum](#supportsampleformatnum) | 支持的音频样本格式数量。 | | [AudioPortCapability::supportSampleFormatNum](#supportsampleformatnum) | 支持的音频样本格式数量。 |
| [AudioPortCapability::supportSampleFormats](#supportsampleformats) | 支持的音频样本格式。 | | [AudioPortCapability::supportSampleFormats](#supportsampleformats) | 支持的音频样本格式。 |
| [AudioMmapBufferDescripter::memoryAddress](#memoryaddress) | 指向mmap缓冲区的指针。 | | [AudioMmapBufferDescriptor::memoryAddress](#memoryaddress) | 指向mmap缓冲区的指针。 |
| [AudioMmapBufferDescripter::memoryFd](#memoryfd) | mmap缓冲区的文件描述符。 | | [AudioMmapBufferDescriptor::memoryFd](#memoryfd) | mmap缓冲区的文件描述符。 |
| [AudioMmapBufferDescripter::totalBufferFrames](#totalbufferframes) | 缓冲区总大小,单位:帧。 | | [AudioMmapBufferDescriptor::totalBufferFrames](#totalbufferframes) | 缓冲区总大小,单位:帧。 |
| [AudioMmapBufferDescripter::transferFrameSize](#transferframesize) | 传输大小,单位:帧。 | | [AudioMmapBufferDescriptor::transferFrameSize](#transferframesize) | 传输大小,单位:帧。 |
| [AudioMmapBufferDescripter::isShareable](#isshareable) | mmap缓冲区是否可以在进程间共享。 | | [AudioMmapBufferDescriptor::isShareable](#isshareable) | mmap缓冲区是否可以在进程间共享。 |
| [AudioDevExtInfo::moduleId](#moduleid-12) | 音频流绑定的模块ID。 | | [AudioDevExtInfo::moduleId](#moduleid-12) | 音频流绑定的模块ID。 |
| [AudioDevExtInfo::type](#type-23) | 音频端口上的PIN脚(输出、输入)。 | | [AudioDevExtInfo::type](#type-23) | 音频端口上的PIN脚(输出、输入)。 |
| [AudioDevExtInfo::desc](#desc-55) | 地址描述。 | | [AudioDevExtInfo::desc](#desc-55) | 地址描述。 |
...@@ -797,7 +797,7 @@ bool AudioSampleAttributes::isBigEndian ...@@ -797,7 +797,7 @@ bool AudioSampleAttributes::isBigEndian
``` ```
int32_t AudioMmapBufferDescripter::isShareable int32_t AudioMmapBufferDescriptor::isShareable
``` ```
**描述:** **描述:**
...@@ -833,7 +833,7 @@ enum AudioPortPassthroughMode AudioSubPortCapability::mask ...@@ -833,7 +833,7 @@ enum AudioPortPassthroughMode AudioSubPortCapability::mask
``` ```
void* AudioMmapBufferDescripter::memoryAddress void* AudioMmapBufferDescriptor::memoryAddress
``` ```
**描述:** **描述:**
...@@ -845,7 +845,7 @@ void* AudioMmapBufferDescripter::memoryAddress ...@@ -845,7 +845,7 @@ void* AudioMmapBufferDescripter::memoryAddress
``` ```
int32_t AudioMmapBufferDescripter::memoryFd int32_t AudioMmapBufferDescriptor::memoryFd
``` ```
**描述:** **描述:**
...@@ -1229,7 +1229,7 @@ enum AudioSampleFormat* AudioPortCapability::supportSampleFormats ...@@ -1229,7 +1229,7 @@ enum AudioSampleFormat* AudioPortCapability::supportSampleFormats
``` ```
int32_t AudioMmapBufferDescripter::totalBufferFrames int32_t AudioMmapBufferDescriptor::totalBufferFrames
``` ```
**描述:** **描述:**
...@@ -1241,7 +1241,7 @@ int32_t AudioMmapBufferDescripter::totalBufferFrames ...@@ -1241,7 +1241,7 @@ int32_t AudioMmapBufferDescripter::totalBufferFrames
``` ```
int32_t AudioMmapBufferDescripter::transferFrameSize int32_t AudioMmapBufferDescriptor::transferFrameSize
``` ```
**描述:** **描述:**
......
...@@ -34,7 +34,7 @@ AudioAttribute音频属性接口。 ...@@ -34,7 +34,7 @@ AudioAttribute音频属性接口。
| ([GetCurrentChannelId](#getcurrentchannelid))(AudioHandle&nbsp;handle,&nbsp;uint32_t&nbsp;\*channelId) | 获取音频的数据通道ID | | ([GetCurrentChannelId](#getcurrentchannelid))(AudioHandle&nbsp;handle,&nbsp;uint32_t&nbsp;\*channelId) | 获取音频的数据通道ID |
| ([SetExtraParams](#setextraparams))(AudioHandle&nbsp;handle,&nbsp;const&nbsp;char&nbsp;\*keyValueList) | 设置音频拓展参数 | | ([SetExtraParams](#setextraparams))(AudioHandle&nbsp;handle,&nbsp;const&nbsp;char&nbsp;\*keyValueList) | 设置音频拓展参数 |
| ([GetExtraParams](#getextraparams))(AudioHandle&nbsp;handle,&nbsp;char&nbsp;\*keyValueList) | 获取音频拓展参数 | | ([GetExtraParams](#getextraparams))(AudioHandle&nbsp;handle,&nbsp;char&nbsp;\*keyValueList) | 获取音频拓展参数 |
| ([ReqMmapBuffer](#reqmmapbuffer))(AudioHandle&nbsp;handle,&nbsp;int32_t&nbsp;reqSize,&nbsp;struct&nbsp;AudioMmapBufferDescripter&nbsp;\*desc) | 请求Mmap缓冲区 | | ([ReqMmapBuffer](#reqmmapbuffer))(AudioHandle&nbsp;handle,&nbsp;int32_t&nbsp;reqSize,&nbsp;struct&nbsp;AudioMmapBufferDescriptor&nbsp;\*desc) | 请求Mmap缓冲区 |
| ([GetMmapPosition](#getmmapposition))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;\*frames,&nbsp;struct&nbsp;AudioTimeStamp&nbsp;\*time) | 获取当前Mmap的读/写位置 | | ([GetMmapPosition](#getmmapposition))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;\*frames,&nbsp;struct&nbsp;AudioTimeStamp&nbsp;\*time) | 获取当前Mmap的读/写位置 |
| ([AddAudioEffect](#addaudioeffect))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;effectid) | 添加音频效果算法实例 | | ([AddAudioEffect](#addaudioeffect))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;effectid) | 添加音频效果算法实例 |
| ([RemoveAudioEffect](#removeaudioeffect))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;effectid) | 移除音频效果算法实例 | | ([RemoveAudioEffect](#removeaudioeffect))(AudioHandle&nbsp;handle,&nbsp;uint64_t&nbsp;effectid) | 移除音频效果算法实例 |
...@@ -260,7 +260,7 @@ int32_t (*AudioAttribute::RemoveAudioEffect)(AudioHandle handle, uint64_t effect ...@@ -260,7 +260,7 @@ int32_t (*AudioAttribute::RemoveAudioEffect)(AudioHandle handle, uint64_t effect
``` ```
int32_t(* AudioAttribute::ReqMmapBuffer) (AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescripter *desc) int32_t(* AudioAttribute::ReqMmapBuffer) (AudioHandle handle, int32_t reqSize, struct AudioMmapBufferDescriptor *desc)
``` ```
**描述:** **描述:**
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- **[AudioMixExtInfo](_audio_mix_ext_info.md)** - **[AudioMixExtInfo](_audio_mix_ext_info.md)**
- **[AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md)** - **[AudioMmapBufferDescriptor](_audio_mmap_buffer_descriptor.md)**
- **[AudioPort](_audio_port.md)** - **[AudioPort](_audio_port.md)**
......
...@@ -34,7 +34,7 @@ Audio模块接口定义中使用的自定义数据类型,包括音频端口、 ...@@ -34,7 +34,7 @@ Audio模块接口定义中使用的自定义数据类型,包括音频端口、
| [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 | | [AudioTimeStamp](_audio_time_stamp.md) | 音频时间戳 |
| [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 | | [AudioSubPortCapability](_audio_sub_port_capability.md) | 音频子端口的支持能力 |
| [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 | | [AudioPortCapability](_audio_port_capability.md) | 音频端口的支持能力 |
| [AudioMmapBufferDescripter](_audio_mmap_buffer_descripter.md) | mmap缓冲区描述符 | | [AudioMmapBufferDescriptor](_audio_mmap_buffer_descriptor.md) | mmap缓冲区描述符 |
| [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息. | | [AudioDevExtInfo](_audio_dev_ext_info.md) | 音频设备拓展信息. |
| [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 | | [AudioMixExtInfo](_audio_mix_ext_info.md) | 音轨拓展信息 |
| [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 | | [AudioSessionExtInfo](_audio_session_ext_info.md) | 会话拓展信息 |
......
...@@ -647,7 +647,7 @@ ...@@ -647,7 +647,7 @@
- [AudioDeviceDescriptor](reference/hdi-apis/_audio_device_descriptor.md) - [AudioDeviceDescriptor](reference/hdi-apis/_audio_device_descriptor.md)
- [AudioManager](reference/hdi-apis/_audio_manager.md) - [AudioManager](reference/hdi-apis/_audio_manager.md)
- [AudioMixExtInfo](reference/hdi-apis/_audio_mix_ext_info.md) - [AudioMixExtInfo](reference/hdi-apis/_audio_mix_ext_info.md)
- [AudioMmapBufferDescripter](reference/hdi-apis/_audio_mmap_buffer_descripter.md) - [AudioMmapBufferDescriptor](reference/hdi-apis/_audio_mmap_buffer_descriptor.md)
- [AudioPort](reference/hdi-apis/_audio_port.md) - [AudioPort](reference/hdi-apis/_audio_port.md)
- [AudioPortCap](reference/hdi-apis/audio_portcap.md) - [AudioPortCap](reference/hdi-apis/audio_portcap.md)
- [AudioPortCapability](reference/hdi-apis/_audio_port_capability.md) - [AudioPortCapability](reference/hdi-apis/_audio_port_capability.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册