

元服务只支持ArkTS卡片,不支持JS卡片。
删除“WidgetCard.ets”文件中默认生成的卡片代码,新增如下示例代码:
@Entry @Component struct WidgetCard { @State x: number = 1 @State y: number = 1 build() { Column() { Button('Click to enlarge') .onClick(() => { this.x = 1.1 this.y = 1.1 }) .scale({ x: this.x, y: this.y }) .animation({ curve: Curve.EaseOut, playMode: PlayMode.AlternateReverse, duration: 200, onFinish: () => { this.x = 1 this.y = 1 } }) } .padding('10vp') .width('100%') .height('100%') .justifyContent(FlexAlign.Center) } }
@Entry @Component struct WidgetCard { @State x: number = 1 @State y: number = 1 build() { Column() { Button('Click to enlarge') .onClick(() => { this.x = 1.1 this.y = 1.1 }) .scale({ x: this.x, y: this.y }) .animation({ curve: Curve.EaseOut, playMode: PlayMode.AlternateReverse, duration: 200, onFinish: () => { this.x = 1 this.y = 1 } }) } .padding('10vp') .width('100%') .height('100%') .justifyContent(FlexAlign.Center) .onClick(() => { postCardAction(this, { "action": 'router', "abilityName": 'EntryAbility', "params": { "message": 'router test' } }); }) } }
