我想要构建一个网格化的应用程序,它可以处理json或YAML文件。
我希望从Vue组件中获取位于"./ data /“文件夹中的文件的值,并保留graphQL数据层。换句话说,在graphQL中公开文件中的数据。
profile.json
{
"name": "Lorem"
}config.json
{
"layout": "default",
"theme": "blue"
}我想以如下方式访问名称值:
$page.data.profile.name
$page.data.config.theme或
$data.profile.name
$data.config.theme我要处理@gridsome/source系统和@gridsome/ deal插件吗?或者手动在服务器中添加“数据”集合并为每个文件添加新节点?
我已经测试和探索了JSON,并返回了一个错误:“在JSON0-JSONAPI中意外的令牌<”
谢谢
发布于 2020-11-25 07:10:00
如果您有本地文件,可以这样添加它们:
import temperatures from '~/data/four.json'
import east from '~/data/east.json'
import southwest from '~/data/southwest.json'
import whd from '~/data/whd.json'
import thirteen from '~/data/thirteen.json'
export default {
data () {
return {
temperatures,
east,
thirteen,
whd,
southwest,
}
},基本上,我在我的页面目录中创建了一个数据文件夹,然后将文件放在它们的目录中。然后,在脚本标记中链接到它们,并使用返回函数调用它们。
在模板标记中,您将执行如下操作:
<template>
<div>
{{ temperatures }}
</div>
</template>https://stackoverflow.com/questions/59361237
复制相似问题