chore: update omi simple example

This commit is contained in:
dntzhang 2021-06-23 10:22:31 +08:00
parent f9baa9b023
commit a2ae0a5c4c
4 changed files with 596 additions and 498 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,8 @@
<body>
<script src="b.js"></script>
<my-component first="dnt" last="zhang"></my-component>
<my-counter count="4">
</my-component>
</body>
</html>

View File

@ -1,14 +1,37 @@
import { define } from '../../src/omi'
import { define, WeElement } from '../../src/omi'
define('my-component', _ =>
<div>
Hello, World! I'm {_.props.first}, {_.props.last}
</div>, {
propTypes: {
first: String,
last: String
}
}
)
define('my-counter', class extends WeElement {
static css = `
span {
color: red;
}`
static propTypes = {
count: Number
}
install() {
this.count = this.props.count
}
sub = () => {
this.count--
this.update()
}
add = () => {
this.count++
this.update()
}
render() {
return (
<div>
<button onClick={this.sub}>-</button>
<span>{this.count}</span>
<button onClick={this.add}>+</button>
</div>
)
}
})