Nuxt.js layout的配置

  1. 创建layouts文件夹(如果有则无需创建)

  2. 在layouts文件夹创建DefaultLayout.vue

  3. DefaultLayout.vue的代码如下:

<template>
  <div>
    <div class="header"> header </div>
    <Nuxt></Nuxt>
    <div class="header"> footer </div>
  </div>
</template>

<script>
export default {
    
    

}
</script>

<style>
.header {
    
    
  background-color: aquamarine;
}
.footer {
    
    
  background-color: blanchedalmond;
}
</style>

  1. 在页面使用:
<template>
  <div>
    <div>main</div>
  </div>
</template>

<script>
export default {
    
    
  layout: 'DefaultLayout'
}
</script>

截图如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41612593/article/details/121125526