繁体   English   中英

类型错误:_this.$content 不是 function - Nuxt.js 内容

[英]TypeError: _this.$content is not a function - Nuxt.js Content

我正在尝试在我的项目中使用 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"]
  }
}

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

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

你应该试试这个

npm install @nuxt/content@1

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM