在 nuxt.js 中添加 cdn 样式表和 javascripts

Dra*_*ier 3 vue.js nuxt.js

嗨,我无法将 fontawesome 添加到我的 nuxt 应用程序中,我尝试将它添加到 nuxt.config.js 中,但它似乎仍然不起作用。

head: {
    title: pkg.name,
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: pkg.description }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/leap-icon.ico' },
      { rel: 'stylesheet', ref: 'https://use.fontawesome.com/releases/v5.2.0/css/all.css' }
    ]
  },
Run Code Online (Sandbox Code Playgroud)

Pra*_*ngh 11

下面是在nuxt中实现外部资源的正确方法。

link: [{ rel:"stylesheet", type:"text/css", href:'http://www.example.com/assets/lib/bootstrap/css/bootstrap.min.css' }]
Run Code Online (Sandbox Code Playgroud)


the*_*ggs 2

我认为只需更改typehref就可以解决问题。例如

  { rel: 'stylesheet', href: 'https://use.fontawesome.com/releases/v5.2.0/css/all.css' }
Run Code Online (Sandbox Code Playgroud)