gpt4 book ai didi

node.js - 如何设置默认页眉和页脚 Nuxt.js?

转载 作者:太空宇宙 更新时间:2023-11-03 23:16:11 24 4
gpt4 key购买 nike

我开始学习Nuxt.js,并且我喜欢Nuxt.js!

但是我遇到了问题:

我想为我的应用程序的所有页面创建页眉和页脚布局(模拟:pug扩展布局)。

我找到了以下方式(nuxt.config.js):

router: {
extendRoutes(routes, resolve) {
routes.push({
name: 'custom',
path: '*',
component: resolve(__dirname, 'layouts/header.vue')
})
}
},

但这不适合我。 :(

我找到了文档(click me):

<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
<head>
{{ HEAD }}
</head>
<body {{ BODY_ATTRS }}>
{{ APP }}
</body>
</html>

我想要设置选项,其中每个页面都会加载我的模式:

<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
<head>
{{ HEAD }}
</head>
<body {{ BODY_ATTRS }}>
{{ HEADER}}
{{ APP }}
{{ FOOTER}}
</body>
</html>

是否可以在 Nuxt.js 中执行类似的操作?

最佳答案

只是你必须在布局目录下准备布局

并为页眉和页脚准备 2 个组件

所以,布局模板将如下所示

<template>
<header_component>
</header_component>
</Nuxt>
<footer_component>
</footer_component>
</template>

关于node.js - 如何设置默认页眉和页脚 Nuxt.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55213470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com