-
Notifications
You must be signed in to change notification settings - Fork 434
/
Copy pathexample.ts
54 lines (48 loc) · 1.03 KB
/
example.ts
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
import * as Vue from 'vue'
import Component from '../lib/index'
@Component({
props: {
propMessage: String
}
})
class App extends Vue {
propMessage: string
msg: number = 123
helloMsg: string = 'Hello, ' + this.propMessage
// lifecycle hook
mounted () {
this.greet()
}
// computed
get computedMsg () {
return 'computed ' + this.msg
}
// method
greet () {
alert('greeting: ' + this.msg)
}
render (h: Vue.CreateElement) {
return (
h('div', [
h('input', {
domProps: { value: this.msg },
on: {
input: (event: any) => {
this.msg = event.target.value
}
}
}),
h('p', ['prop: ', this.propMessage]),
h('p', ['msg: ', this.msg]),
h('p', ['helloMsg: ', this.helloMsg]),
h('p', ['computed msg: ', this.computedMsg]),
h('button', { on: { click: this.greet }}, ['Greet'])
])
)
}
}
// mount
new App({
el: '#el',
render: h => h(App, { props: { propMessage: 'World!' }})
})