小编Meh*_*iee的帖子

Nuxt 从资产问题中链接 Head 属性中的 CSS 文件

我试图通过仅在一个特定页面中使用 nuxt 的 head 属性来链接我的 css 文件,如下所示:

  head: {
    link: [
      {rel: 'stylesheet', href: require('~/assets/css/font.css')},
      {rel: 'stylesheet', href: require('~/assets/css/style.css')},
    ]
}
Run Code Online (Sandbox Code Playgroud)

执行此操作后,当我加载页面时一切都很好,但我在控制台 GET http://localhost:3000/[object%20Object] net::ERR_ABORTED 404 (Not Found)看到此错误

当我查看源代码时,我发现 CSS 文件是这样链接的:

<link data-n-head="ssr" rel="stylesheet" href="[object Object]">
<link data-n-head="ssr" rel="stylesheet" href="[object Object]">
Run Code Online (Sandbox Code Playgroud)

我需要以这种方式导入我的CSS,但我仍然遇到这个问题,我该如何解决这个问题?

vue.js vuejs2 nuxt.js nuxtjs

5
推荐指数
1
解决办法
1万
查看次数

当其中一个 API 响应未经授权的 401 (Nuxt-Auth) 时如何注销用户

当 API 之一使用 Nuxt-Auth 响应未经授权的 401 时如何注销用户?我使用 AXIOS 和 Nuxt-Auth 的内置函数来请求

我的 nuxt-auth 的 nuxt-config 设置:

    auth: {
        redirect: {
            login: '/login',
            logout: '/',
            callback: '/login',
            home: '/panel/dashboard'
        },
        strategies: {
            local: {
                token: {
                    property: 'token',
                    global: true,
                    type: 'Bearer',
                    required: true,
                },
                user: {
                    property: 'user',
                    autoFetch: true
                },
                endpoints: {
                    login: {url: '/api/auth/login_verify', method: 'post'},
                    logout: {url: '/api/auth/logout', method: 'get'},
                    user: {url: '/api/auth/validate', method: 'get'},
                },
            },
        }
    },
Run Code Online (Sandbox Code Playgroud)

javascript vue.js nuxt.js nuxt-auth

0
推荐指数
1
解决办法
2117
查看次数

标签 统计

nuxt.js ×2

vue.js ×2

javascript ×1

nuxt-auth ×1

nuxtjs ×1

vuejs2 ×1