Skip to content

Commit

Permalink
feat: add no layout support
Browse files Browse the repository at this point in the history
  • Loading branch information
xbmlz committed Aug 24, 2022
1 parent 030d060 commit eaaa8c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
5 changes: 5 additions & 0 deletions examples/spa/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
sub layout
</router-link>
</p>
<p>
<router-link to="/nolayout">
no layout
</router-link>
</p>
</div>
</template>

Expand Down
10 changes: 10 additions & 0 deletions examples/spa/src/pages/nolayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<div>
<p>nolayout</p>
</div>
</template>

<route lang="yaml">
meta:
layout: false
</route>
14 changes: 10 additions & 4 deletions src/RouteLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ ${importCode}
export function setupLayouts(routes) {
return routes.map(route => {
return {
path: route.path,
component: layouts[route.meta?.layout || '${options.defaultLayout}'],
children: [ {...route, path: ''} ],
const isBoolean = typeof route.meta?.layout === 'boolean'
if(isBoolean && !route.meta?.layout) {
return route
} else {
let componentName = !isBoolean && route.meta?.layout ? route.meta?.layout : '${options.defaultLayout}'
return {
path: route.path,
component: layouts[componentName],
children: [ {...route, path: ''} ],
}
}
})
}
Expand Down

0 comments on commit eaaa8c3

Please sign in to comment.