-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (53 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {Muse} from '../index';
import ListItem from './components/listItem';
class App extends Muse {
state = {
name: 'Joe',
age: 22,
langs: [
'JavaScript',
'Python',
'Rust',
'Scala'
],
showHello: true,
color: ''
}
computed = {
isAgeOdd() {
return this.state.age % 2 !== 0
}
}
handleClick = () => {
this.state.age++;
}
render() {
return (
<div>
<h1 if={this.state.showHello}>Hello!</h1>
<input
type="password"
model={this.state.name}
/>
<input
type="checkbox"
model={this.state.showHello}
/>
<p style={{color: this.state.color}}>{this.state.color}</p>
<input type="color" model={this.state.color}/>
<p>My name is {this.state.name}.</p>
<p>
I'm {this.state.age} years old
<span if={this.computed.isAgeOdd}> and it's an odd number.</span>
</p>
<p>And I can those programming languages:</p>
<ul>
<ListItem for={lang in this.state.langs} text={lang}/>
</ul>
<button onClick={this.handleClick}>Click Me</button>
</div>
)
}
}
const app = new App();
app.renderTo(document.getElementById('root'));