使用 Nuxt 中的 Fetch 使用静态 json 文件创建博客。如何使用 slug 获取特定节点的内容?
Create blog with Static json file with Fetch in Nuxt. How to use slug to get content of specific node?
我正在尝试在 Nuxt(带有 http 模块)中使用静态 json 文件构建博客。
使用 Nuxt 'Mountains' 示例作为基础,进行测试。我在 'static' 文件夹中将 api 响应保存为 json。
(示例在这里:https://nuxtjs.org/examples/data-fetching-fetch-hook)
正在使用 'fetch' 连接到博客页面静态文件夹中的 json。
参见:https://3udju.sse.codesandbox.io/blog
使用 Fetch 识别个人时遇到问题 node/content。
参见:https://3udju.sse.codesandbox.io/blog/mount-everest(此处无内容)
我不知道如何重新创建这个 - 使用本地 Json 文件而不是 Api url:
https://api.nuxtjs.dev/mountains/${this.$route.params.slug}
和 _slug.vue 文件:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/blog/_slug.vue
已尝试在 Fetch 上使用过滤器。已尝试将不同的查询字符串作为 .json 上的参数,但它不起作用。
已搜索:
- 从 json slug id
获取数据
- 根据本地的 slug 获取对象 json
- 在 slug
上获取本地 json 过滤器
观看了几个关于 Fetch 的 youtube,但没有找到任何东西。
如果有人有线索或可以指出我的解决方案,非常感谢。
找到了在 Nuxt 的内容模块中使用静态 json 的方法。此处示例:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/cars/index.vue
另请参阅 'Content' 文件夹中的 'cars.json'。
前端:https://3udju.sse.codesandbox.io/cars(将山重新用作汽车;-)
我正在尝试在 Nuxt(带有 http 模块)中使用静态 json 文件构建博客。
使用 Nuxt 'Mountains' 示例作为基础,进行测试。我在 'static' 文件夹中将 api 响应保存为 json。
(示例在这里:https://nuxtjs.org/examples/data-fetching-fetch-hook)
正在使用 'fetch' 连接到博客页面静态文件夹中的 json。
参见:https://3udju.sse.codesandbox.io/blog
使用 Fetch 识别个人时遇到问题 node/content。
参见:https://3udju.sse.codesandbox.io/blog/mount-everest(此处无内容)
我不知道如何重新创建这个 - 使用本地 Json 文件而不是 Api url:
https://api.nuxtjs.dev/mountains/${this.$route.params.slug}
和 _slug.vue 文件:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/blog/_slug.vue
已尝试在 Fetch 上使用过滤器。已尝试将不同的查询字符串作为 .json 上的参数,但它不起作用。
已搜索:
- 从 json slug id 获取数据
- 根据本地的 slug 获取对象 json
- 在 slug 上获取本地 json 过滤器
观看了几个关于 Fetch 的 youtube,但没有找到任何东西。
如果有人有线索或可以指出我的解决方案,非常感谢。
找到了在 Nuxt 的内容模块中使用静态 json 的方法。此处示例:
https://codesandbox.io/s/nuxt-http-fetch-static-json-3udju?file=/pages/cars/index.vue 另请参阅 'Content' 文件夹中的 'cars.json'。 前端:https://3udju.sse.codesandbox.io/cars(将山重新用作汽车;-)