【问题标题】:TypeError: _this.$content is not a function - Nuxt.js ContentTypeError:_this.$content 不是函数 - Nuxt.js 内容
【发布时间】:2022-08-05 13:54:20
【问题描述】:

我正在尝试在我的项目中使用 Nuxt.js 内容。 问题是当我尝试在我的项目中使用 $content 方法时,TypeError: _this.$content is not a function 会发生:

async fetch() {
  this.content = await this.$content(\'data\').fetch()
},

我在 Nuxt 配置和 typescript 配置中导入了 @nuxt/content

nuxt.config.js

export default {
  modules: [\'@nuxt/content\']
}

tsconfig.json

{
  \"compilerOptions\": {
    \"types\": [\"@nuxt/types\", \"@types/node\", \"@nuxt/content\"]
  }
}
  • 您使用哪个版本的内容?最新的需要 Nuxt3。
  • @kissu 我正式爱你,伙计。更改为 ^1 后,它现在正在工作。非常感谢<333

标签: javascript typescript vue.js nuxt.js


【解决方案1】:

Nuxt 内容 v2 需要 Nuxt3。如果您使用的是 Nuxt2,则应使用 v1。

如本页末尾所述:https://content.nuxtjs.org/get-started#render-pages

【讨论】:

    【解决方案2】:

    你应该试试这个

    npm install @nuxt/content@1
    

    原因我楼上的兄弟已经解释过了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-29
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2021-04-22
      • 2021-03-11
      相关资源
      最近更新 更多