从 Nuxt 配置文件提供资产
Serving assets from Nuxt config file
我找到了一个在线 bootstrap 模板,我正尝试将其改编为 nuxt 项目的一部分。我已将所有 bootstrap 文件放在静态文件夹中。
在 nuxt.config.js 文件中:
module.exports = {
/*
** Headers of the page
*/
head: {
title: ' Bootstrap Responsive Website Template | Home :: w3layouts',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/style.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/flexslider.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/easy-responsive-tabs.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/chocolat.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/bootstrap.min.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/font-awesome.min.css' },
]
},
但是路径错误,css 不工作。我怎样才能让它工作?
CSS 在 Nuxt 配置中有自己的 属性。
https://nuxtjs.org/api/configuration-css/
header stuff....
css: [
{ '/css/style.css' },
{ '/css/flexslider.css' },
{ '/css/easy-responsive-tabs.css' },
{ '/css/chocolat.css' },
{ '/css/bootstrap.min.css' },
{ '/css/font-awesome.min.css' },
]
CSS 属性 不在 header 本身,它有自己的意义。
请注意,在 Nuxt 中,静态文件夹的标准路径很简单 /
如果这不起作用,您也可以尝试 @/static/...
我找到了一个在线 bootstrap 模板,我正尝试将其改编为 nuxt 项目的一部分。我已将所有 bootstrap 文件放在静态文件夹中。
在 nuxt.config.js 文件中:
module.exports = {
/*
** Headers of the page
*/
head: {
title: ' Bootstrap Responsive Website Template | Home :: w3layouts',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/style.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/flexslider.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/easy-responsive-tabs.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/chocolat.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/bootstrap.min.css' },
{ rel: 'stylesheet', type: 'text/css', href: '/static/css/font-awesome.min.css' },
]
},
但是路径错误,css 不工作。我怎样才能让它工作?
CSS 在 Nuxt 配置中有自己的 属性。 https://nuxtjs.org/api/configuration-css/
header stuff....
css: [
{ '/css/style.css' },
{ '/css/flexslider.css' },
{ '/css/easy-responsive-tabs.css' },
{ '/css/chocolat.css' },
{ '/css/bootstrap.min.css' },
{ '/css/font-awesome.min.css' },
]
CSS 属性 不在 header 本身,它有自己的意义。
请注意,在 Nuxt 中,静态文件夹的标准路径很简单 /
如果这不起作用,您也可以尝试 @/static/...