chore: update omi simple example
This commit is contained in:
parent
f9baa9b023
commit
a2ae0a5c4c
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue