This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/js-framework/demo.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-07-22 13:52:30 +08:00
import { NativeCall, Text, Alignment, Color, VLayout, Panel, log, logw, loge } from "./index"
2019-07-22 14:36:32 +08:00
import { Group } from "./src/ui/view";
2019-07-18 16:29:24 +08:00
2019-07-18 20:11:01 +08:00
2019-07-22 13:41:38 +08:00
@Entry
2019-07-18 16:29:24 +08:00
export class MyPage extends Panel {
2019-07-23 13:01:45 +08:00
state = {
count: 0
}
2019-07-22 14:36:32 +08:00
build(rootView: Group): void {
2019-07-23 13:01:45 +08:00
const numberView = new Text
numberView.width = 100
numberView.height = 200
numberView.top = 50
numberView.text = this.state.count.toString()
numberView.textSize = 40
numberView.centerX = rootView.width / 2
rootView.addChild(numberView)
const click = new Text
click.width = click.height = 100
click.textSize = 20
click.text = '点击计数'
click.onClick = () => {
this.state.count++
numberView.text = this.state.count.toString()
}
click.centerX = rootView.width / 2
click.top = numberView.bottom + 20
rootView.addChild(click)
2019-07-22 15:38:30 +08:00
rootView.bgColor = Color.safeParse('#00ff00')
2019-07-18 16:29:24 +08:00
}
2019-07-22 14:36:32 +08:00
2019-07-22 13:41:38 +08:00
@NativeCall
2019-07-18 16:29:24 +08:00
log() {
2019-07-22 13:41:38 +08:00
log("Hello.HEGO")
logw("Hello.HEGO")
loge("Hello.HEGO")
2019-07-18 16:29:24 +08:00
}
}