MCPcopy
hub / github.com/nuxt/nuxt / setup

Function setup

test/nuxt/nuxt-layout.test.ts:28–52  ·  view source on GitHub ↗
(_, ctx)

Source from the content-addressed store, hash-verified

26 for (const layout of addedLayouts) {
27 layouts[layout] = defineComponent({
28 setup (_, ctx) {
29 const route = useRoute()
30 watch(() => route.path, () => routeChanges++, { immediate: true })
31 const fixed = route.path
32
33 const key = `[layout] ${layout}`
34 setups[key] ??= 0
35 setups[key]++
36
37 return () => {
38 renders[key] ??= 0
39 renders[key]++
40
41 // console.log([
42 // `'${layout}' layout`,
43 // 'Current route: ' + route.path + ` (initialised at: ${fixed})`,
44 // ])
45
46 return h('div', {}, [
47 h('h1', `'${layout}' layout`),
48 h('h2', 'Current route: ' + route.path + ` (initialised at: ${fixed})`),
49 ...ctx.slots.default?.() || [],
50 ])
51 }
52 },
53 })
54 }
55 for (const page of addedPages) {

Callers

nothing calls this directly

Calls 3

useRouteFunction · 0.90
watchFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…