File size: 3,618 Bytes
4d70170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<script>
import { createApp, h } from 'vue'
import Child from './Child.vue'
import NestedMore from './NestedMore.vue'
import NativeTypes from './NativeTypes.vue'
import EventEmit from './EventEmit.vue'
import EventNesting from './EventNesting.vue'
import AsyncComponent from './AsyncComponent.vue'
import SuspenseExample from './SuspenseExample.vue'
import Provide from './Provide.vue'
import Condition from './Condition.vue'
import VModelExample from './VModelExample.vue'
import Ghost from './Ghost.vue'
import Other from './Other.vue'
import SetupRender from './SetupRender.js'
import MyForm from './Form.vue'
import Functional from './Functional.vue'
import Heavy from './Heavy.vue'
import Mixins from './Mixins.vue'
import Animation from './Animation.vue'
import SetupScript from './SetupScript.vue'
import SetupDataLike from './SetupDataLike.vue'
import SetupTSScriptProps from './SetupTSScriptProps.vue'
import DomOrder from './DomOrder.vue'
import IndexComponent from './IndexComponent/index.vue'

import SimplePlugin from './devtools-plugin/simple'

export default {
  name: 'MyApp',

  components: {
    Child,
    NestedMore,
    NativeTypes,
    EventEmit,
    EventNesting,
    AsyncComponent,
    SuspenseExample,
    Provide,
    Condition,
    VModelExample,
    Ghost,
    Other,
    SetupRender,
    MyForm,
    Functional,
    Heavy,
    Mixins,
    Animation,
    SetupScript,
    SetupDataLike,
    SetupTSScriptProps,
    DomOrder,
    IndexComponent,
    Inline: {
      render: () => h('h3', 'Inline component definition'),
    },
  },

  data() {
    return {
      count: 0,
      text: 'Meow',
      time: 0,
    }
  },

  methods: {
    createApp() {
      const app = createApp(Child)
      app.use(SimplePlugin)
      app.mount('#nested-app')
    },

    startTimer() {
      this.stopTimer()
      this.timer = setInterval(() => {
        this.time++
      }, 1)
    },

    stopTimer() {
      clearInterval(this.timer)
    },

    onFoo(...args) {
      console.log('on foo', ...args)
    },

    onBar(...args) {
      console.log('on bar', ...args)
    },
  },
}
</script>

<template>
  <h1>Hello from Vue 3</h1>

  <div style="margin-bottom: 12px;">
    {{ count }} <button @click="count++">
      +1
    </button>
    <input v-model="text">
    <span>{{ text }}</span>
  </div>

  <div>
    <button @click="startTimer">
      Start timer
    </button>
    <button @click="stopTimer">
      Stop timer
    </button>
    <span>{{ time }}</span>
  </div>

  <div>
    <Heavy
      v-for="i in count"
      :key="i"
    />
  </div>

  <Child question="Life" />
  <IndexComponent />
  <NestedMore />
  <NativeTypes ref="nativeTypes" />
  <EventEmit
    @foo="onFoo"
    @bar="onBar"
  />
  <EventNesting />
  <AsyncComponent />
  <SuspenseExample />
  <Provide />
  <Animation />
  <Condition />
  <VModelExample />
  <Ghost />
  <Other />
  <SetupRender />
  <MyForm />
  <Functional msg="I am functional" />
  <Mixins />
  <SetupScript />
  <SetupDataLike />
  <SetupTSScriptProps my-prop="42" />
  <DomOrder />
  <Inline />
  <global />

  <h2>Store</h2>
  <div>
    {{ $store.getters.answer }}
    <button @click="$store.commit('increment')">
      +1
    </button>
    {{ $store.getters.twoFoo }}
  </div>

  <button @click="createApp()">
    Create nested app
  </button>
  <div id="nested-app" />

  <nav>
    <router-link to="/p1">
      page 1
    </router-link>
    |
    <router-link to="/p2">
      page 2
    </router-link>
  </nav>

  <router-view v-slot="{ Component }">
    <keep-alive>
      <component :is="Component" />
    </keep-alive>
  </router-view>
</template>