我试图在我的项目中使用nuext .js内容。问题是,当我试图在我的项目中使用$内容方法TypeError: _this.$content is not a function
发生:
async fetch() {
this.content = await this.$content('data').fetch()
},
我在next配置和typescript配置中导入了@nuxt/content
。
nuxt.config.js
export default {
modules: ['@nuxt/content']
}
tsconfig.json
{
"compilerOptions": {
"types": ["@nuxt/types", "@types/node", "@nuxt/content"]
}
}
next content v2需要Nuxt3。如果您使用的是Nuxt2,则应该使用v1。
如本页末尾所述:https://content.nuxtjs.org/get-started#render-pages