1// layouts/error.vue
2<template>
3 <div class="nuxt-error">
4 <component :is="errorPage" :error="error" />
5 </div>
6</template>
7<script>
8import error404 from '~/components/error/404.vue';
9import error500 from '~/components/error/500.vue';
10export default {
11 name: 'nuxt-error',
12 layout: 'default', // optional
13 props: {
14 error: {
15 type: Object,
16 default: () => {},
17 },
18 },
19 computed: {
20 errorPage() {
21 if (this.error.statusCode === 404) {
22 return error404;
23 }
24 // catch everything else
25 return error500;
26 },
27};
28</script>