Vuejs2 Nuxt.js-如何有单独的布局?
在我的默认布局中,每页都有页眉和页脚。但是在Vuejs2 Nuxt.js-如何有单独的布局?,vuejs2,nuxt.js,Vuejs2,Nuxt.js,在我的默认布局中,每页都有页眉和页脚。但是在错误页面中我需要一个没有页眉和页脚的完整页面。所以我做了另一个布局,我在导出默认值部分调用它。但它仍然有页眉和页脚 default.vue 我哪里错了?你可以这样做 1 - create a layouterror.vue file inside layouts folder (Put nothing inside just the basic code). <template> <div>
错误页面中
我需要一个没有页眉和页脚的完整页面。所以我做了另一个布局,我在导出默认值部分调用它。但它仍然有页眉和页脚
default.vue
我哪里错了?你可以这样做
1 - create a layouterror.vue file inside layouts folder (Put nothing inside just the basic code).
<template>
<div>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
2 - create a error.vue file inside layouts folder.
3 - and pass your error file a layout like this =>
export default {
layout: 'layouterror'
}
1-在layouts文件夹中创建layouterror.vue文件(仅在基本代码中不放任何内容)。
导出默认值{}
2-在layouts文件夹中创建error.vue文件。
3-并向错误文件传递如下布局=>
导出默认值{
布局:“layouterror”
}
也许会有帮助
谢谢 你可以这样做
1 - create a layouterror.vue file inside layouts folder (Put nothing inside just the basic code).
<template>
<div>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
2 - create a error.vue file inside layouts folder.
3 - and pass your error file a layout like this =>
export default {
layout: 'layouterror'
}
1-在layouts文件夹中创建layouterror.vue文件(仅在基本代码中不放任何内容)。
导出默认值{}
2-在layouts文件夹中创建error.vue文件。
3-并向错误文件传递如下布局=>
导出默认值{
布局:“layouterror”
}
也许会有帮助
谢谢 在名为layouts的Nuxt项目文件夹中,创建一个名为error.vue的文件,它将自动检测所有未找到页面的404错误 error.vue
哎呀,出问题了!
回来
.错误页{
文本对齐:居中;
}
.错误页a{
文字装饰:无;
颜色:红色;
}
.错误页面a:悬停,
.错误页面a:活动{
颜色:三文鱼;
}
在名为layouts的Nuxt项目文件夹上,创建一个名为error.vue的文件,它将自动检测所有未找到页面的404错误
error.vue
哎呀,出问题了!
回来
.错误页{
文本对齐:居中;
}
.错误页a{
文字装饰:无;
颜色:红色;
}
.错误页面a:悬停,
.错误页面a:活动{
颜色:三文鱼;
}
仍显示带有页眉和页脚的我错误页面
(仍显示带有页眉和页脚的我错误页面
:(同样的事情也发生在我身上,这曾经是一个缺陷。可能是回归?我现在正在努力弄清楚。同样的事情也发生在我身上,曾经是一个缺陷。可能是回归?我现在正在努力弄清楚。
<template>
<div class="container">
<h1 v-if="error.statusCode === 404">Page not found</h1>
<h1 v-else>An error occurred</h1>
<nuxt-link to="/">Home page</nuxt-link>
</div>
</template>
<script>
export default {
props: ['error'],
layout: 'fullpage' // you can set a custom layout for the error page
}
</script>
fullpage.vue
<template>
<div>
<nuxt />
</div>
</template>
1 - create a layouterror.vue file inside layouts folder (Put nothing inside just the basic code).
<template>
<div>
</div>
</template>
<script>
export default {}
</script>
<style>
</style>
2 - create a error.vue file inside layouts folder.
3 - and pass your error file a layout like this =>
export default {
layout: 'layouterror'
}
<template>
<div class="error-page">
<h1>Oops, something went wrong!</h1>
<p>Back to <a href="/">safety</a>!</p>
</div>
</template>
<style scoped>
.error-page {
text-align: center;
}
.error-page a {
text-decoration: none;
color: red;
}
.error-page a:hover,
.error-page a:active {
color: salmon;
}
</style>