|
183 | 183 | </div> |
184 | 184 | </template> |
185 | 185 |
|
186 | | -<script lang="ts"> |
187 | | -import { defineComponent, inject, computed, ref } from 'vue' |
| 186 | +<script lang="ts" setup> |
| 187 | +import { inject, computed, ref } from 'vue' |
188 | 188 | import { scrollWaiter } from './scrollWaiter' |
189 | | -import { useLink, useRoute } from 'vue-router' |
| 189 | +import { useLink, useRoute, RouterLink } from 'vue-router' |
190 | 190 | import AppLink from './AppLink.vue' |
191 | 191 |
|
192 | | -export default defineComponent({ |
193 | | - name: 'App', |
194 | | - components: { AppLink }, |
195 | | - setup() { |
196 | | - const route = useRoute() |
197 | | - const state = inject('state') |
198 | | - const viewName = ref('default') |
| 192 | +const route = useRoute() |
| 193 | +const state = inject('state') |
| 194 | +const viewName = ref('default') |
199 | 195 |
|
200 | | - useLink({ to: '/' }) |
201 | | - useLink({ to: '/documents/hello' }) |
202 | | - useLink({ to: '/children' }) |
| 196 | +useLink({ to: '/' }) |
| 197 | +useLink({ to: '/documents/hello' }) |
| 198 | +useLink({ to: '/children' }) |
203 | 199 |
|
204 | | - const currentLocation = computed(() => { |
205 | | - const { matched, ...rest } = route |
206 | | - return rest |
207 | | - }) |
| 200 | +const currentLocation = computed(() => { |
| 201 | + const { matched, ...rest } = route |
| 202 | + return rest |
| 203 | +}) |
208 | 204 |
|
209 | | - function flushWaiter() { |
210 | | - scrollWaiter.flush() |
211 | | - } |
212 | | - function setupWaiter() { |
213 | | - scrollWaiter.add() |
214 | | - } |
| 205 | +function flushWaiter() { |
| 206 | + scrollWaiter.flush() |
| 207 | +} |
| 208 | +function setupWaiter() { |
| 209 | + scrollWaiter.add() |
| 210 | +} |
215 | 211 |
|
216 | | - const nextUserLink = computed( |
217 | | - () => '/users/' + String((Number(route.params.id) || 0) + 1) |
218 | | - ) |
| 212 | +const nextUserLink = computed( |
| 213 | + () => '/users/' + String((Number(route.params.id) || 0) + 1) |
| 214 | +) |
219 | 215 |
|
220 | | - return { |
221 | | - currentLocation, |
222 | | - nextUserLink, |
223 | | - state, |
224 | | - flushWaiter, |
225 | | - setupWaiter, |
226 | | - viewName, |
227 | | - toggleViewName() { |
228 | | - viewName.value = viewName.value === 'default' ? 'other' : 'default' |
229 | | - }, |
230 | | - } |
231 | | - }, |
232 | | -}) |
| 216 | +function toggleViewName() { |
| 217 | + viewName.value = viewName.value === 'default' ? 'other' : 'default' |
| 218 | +} |
233 | 219 | </script> |
0 commit comments