-
Notifications
You must be signed in to change notification settings - Fork 430
Expand file tree
/
Copy pathApp.vue
More file actions
53 lines (46 loc) · 899 Bytes
/
App.vue
File metadata and controls
53 lines (46 loc) · 899 Bytes
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
<template>
<div>
<input v-model="msg">
<p>prop: {{ propMessage }}</p>
<p>msg: {{ msg }}</p>
<p>helloMsg: {{ helloMsg }}</p>
<p>computed msg: {{ computedMsg }}</p>
<comp />
<comp2 />
<p>
<button @click="greet">Greet</button>
</p>
</div>
</template>
<script lang="ts">
import { Vue, Options } from '../../src'
import Comp from './Comp.vue'
import Comp2 from './Comp2.vue'
class Props {
propMessage!: string
}
@Options({
components: {
Comp,
Comp2
}
})
export default class App extends Vue.with(Props) {
// inital data
msg: number = 123
// use prop values for initial data
helloMsg: string = 'Hello, ' + this.propMessage
// lifecycle hook
mounted () {
this.greet()
}
// computed
get computedMsg () {
return 'computed ' + this.msg
}
// method
greet () {
alert('greeting: ' + this.msg)
}
}
</script>