未验证 提交 1344bf60 编写于 作者: O openharmony_ci 提交者: Gitee

!23197 apis下示例代码修改

Merge pull request !23197 from 椎名真昼/master
......@@ -279,9 +279,9 @@ customCurve(interpolate: (fraction: number) => number): ICurve
```ts
import Curves from '@ohos.curves'
let interpolate = function(fraction) {
return Math.sqrt(fraction)
}
let interpolate = (fraction:number):number => {
return Math.sqrt(fraction)
}
let curve = Curves.customCurve(interpolate) // 创建一个用户自定义插值曲线
```
......
......@@ -104,7 +104,7 @@ import font from '@ohos.font';
@Entry
@Component
struct FontExample {
fontList: Array<string>;
fontList: Array<string> = new Array<string>();
build() {
Column() {
Button("getSystemFontList")
......@@ -164,8 +164,8 @@ import font from '@ohos.font';
@Entry
@Component
struct FontExample {
fontList: Array<string>;
fontInfo: font.FontInfo;
fontList: Array<string> = new Array<string>();
fontInfo: font.FontInfo = font.getFontByName('');
build() {
Column() {
Button("getFontByName")
......
......@@ -561,9 +561,9 @@ import matrix4 from '@ohos.matrix4'
@Entry
@Component
struct Test {
private originPoint: [number, number] = [50, 50]
private originPoint: number[] = [50, 50]
private matrix_1 = matrix4.identity().translate({ x: 150, y: -50 })
private transformPoint = this.matrix_1.transformPoint(this.originPoint)
private transformPoint = this.matrix_1.transformPoint([this.originPoint[0], this.originPoint[1]])
private matrix_2 = matrix4.identity().translate({ x: this.transformPoint[0], y: this.transformPoint[1] })
build() {
......
......@@ -30,14 +30,14 @@ matchMediaSync(condition: string): MediaQueryListener
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ---------------------------------------- |
| condition | string | 是 | 媒体事件的匹配条件,具体可参考[媒体查询语法规则](../../ui/arkts-layout-development-media-query.md#语法规则)。 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------------------------------------------------ |
| condition | string | 是 | 媒体事件的匹配条件,具体可参考[媒体查询语法规则](../../ui/arkts-layout-development-media-query.md#语法规则)。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | ---------------------- |
| 类型 | 说明 |
| ------------------ | -------------------------------------------- |
| MediaQueryListener | 媒体事件监听句柄,用于注册和去注册监听回调。 |
**示例:**
......@@ -71,10 +71,10 @@ on(type: 'change', callback: Callback&lt;MediaQueryResult&gt;): void
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ---------------- |
| type | string | 是 | 必须填写字符串'change'。 |
| callback | Callback&lt;MediaQueryResult&gt; | 是 | 向媒体查询注册的回调 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ------------------------ |
| type | string | 是 | 必须填写字符串'change'。 |
| callback | Callback&lt;MediaQueryResult&gt; | 是 | 向媒体查询注册的回调 |
**示例:**
......@@ -102,7 +102,7 @@ off(type: 'change', callback?: Callback&lt;MediaQueryResult&gt;): void
import mediaquery from '@ohos.mediaquery'
let listener = mediaquery.matchMediaSync('(orientation: landscape)'); //监听横屏事件
function onPortrait(mediaQueryResult) {
function onPortrait(mediaQueryResult:mediaquery.MediaQueryResult) {
if (mediaQueryResult.matches) {
// do something here
} else {
......@@ -141,7 +141,7 @@ struct MediaQueryExample {
@State text: string = 'Portrait'
listener = mediaquery.matchMediaSync('(orientation: landscape)')
onPortrait(mediaQueryResult) {
onPortrait(mediaQueryResult:mediaquery.MediaQueryResult) {
if (mediaQueryResult.matches) {
this.color = '#FFD700'
this.text = 'Landscape'
......@@ -152,7 +152,7 @@ struct MediaQueryExample {
}
aboutToAppear() {
let portraitFunc = this.onPortrait.bind(this) // bind current js instance
let portraitFunc = (mediaQueryResult:mediaquery.MediaQueryResult):void=>this.onPortrait(mediaQueryResult) // bind current js instance
this.listener.on('change', portraitFunc)
}
......
......@@ -98,7 +98,10 @@ addListener(callback: (event: MediaQueryEvent) => void): void
**示例:**
```ts
function maxWidthMatch(e){
import mediaquery, { MediaQueryEvent } from '@system.mediaquery';
let mMediaQueryList = mediaquery.matchMedia('(max-width: 466)');
function maxWidthMatch(e: MediaQueryEvent): void {
if(e.matches){
// do something
}
......@@ -124,13 +127,13 @@ removeListener(callback: (event: MediaQueryEvent) => void): void
**示例:**
```ts
function maxWidthMatch(e){
import mediaquery, { MediaQueryEvent } from '@system.mediaquery';
let mMediaQueryList = mediaquery.matchMedia('(max-width: 466)');
function maxWidthMatch(e: MediaQueryEvent): void {
if(e.matches){
// do something
}
}
mMediaQueryList.removeListener(maxWidthMatch);
```
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册