首页 > 解决方案 > 我在使用 Gridsome 和 Directus 显示子页面时遇到问题

问题描述

谢谢阅读!

我正在尝试在我的 Gridsome Directus 项目中显示子页面。

我在模板目录中有一个 Shop.vue 模板。

我正在使用@pienter/gridsome-source-directus并尝试过 gridsome-source-directus。

下面的代码是我添加的。到目前为止,我在网上找不到任何可以帮助解决问题的东西,而且我在文档中也没有看到任何可以帮助我的东西。

一些gridsome.config.js

`module.exports = {
    templates: {
        Shop: [
            {
                path: '/shop/:id',
                component: 'templates/Shop.vue'
            }
        ]
    },
    {
        use: '@pienter/gridsome-source-directus',
        options: {
            routes: {
            shop: '/shop/:slug',
        },
    },
    }`
Error: child "path" fails because ["path" is required] at vaidateOptions (C:\wamp64\www\gridsome\node_modules\gridsome\lib\pages\validateOptions.js:20:11) at Pages._normalizeOptions (C:\wamp64\www\gridsome\node_modules\gridsome\lib\pages\pages.js:166:21) at Pages.createPage (C:\wamp64\www\gridsome\node_modules\gridsome\lib\pages\pages.js:83:26) at Object.createPage (C:\wamp64\www\gridsome\node_modules\gridsome\lib\pages\utils.js:33:20) at VueTemplates.createNodePage (C:\wamp64\www\sites\gridsome\node_modules\gridsome\lib\plugins\vue-templates\index.js:85:23) at contentType.collection.find.forEach.node (C:\wamp64\www\gridsome\node_modules\gridsome\lib\plugins\vue-templates\index.js:53:12) at Array.forEach (<anonymous>) at VueTemplates.createTemplate (C:\wamp64\www\gridsome\node_modules\gridsome\lib\plugins\vue-templates\index.js:52:35) at VueTemplates.createTemplates (C:\wamp64\www\gridsome\node_modules\gridsome\lib\plugins\vue-templates\index.js:30:12) at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

标签: vue.jsdirectusgridsome

解决方案


Add a field "path" to each collection of that value. How strange.


推荐阅读