我正在使用Vue.js
并Gridsome
为自己创建一个投资组合。但是,当我在站点中添加一个 JSON 文件以包含我的个人资料信息时,我遇到了一个问题。这就是我在Index.vue
组件中导入文件的方式:
<script>
import Intro from "~/components/Intro.vue";
import profile from "~/data/profile.json";
export default {
components: {
Intro,
},
metaInfo: {
title: "Farzin Nasiri",
},
data: () => ({
profile
}),
};
</script>
这是我使用它的方式:
<Intro :personal="profile.personal" />
当我在开发中运行项目(命令gridsome develop
:)时,一切正常并且数据被正确读取。但是,当我想构建在文件夹gridsome build
中创建构建文件的项目(命令dist
:)时,会发生此错误:
Initializing plugins...
Load sources - 0.04s
Create GraphQL schema - 0.05s
Create pages and templates - 0.03s
Generate temporary code - 0.03s
Bootstrap finish - 0.67s
Compile assets - 13.28s
Execute GraphQL (6 queries) - 0.03s
Write out page data (6 files) - 0s
Could not generate HTML for "/":
TypeError: Cannot read property '__esModule' of undefined
at i (/home/farzin/MyProjects/portfolio.farzinnasiri.com/node_modules/vue-server-renderer/build.prod.js:1:68670)
这是我的项目结构(src 文件夹):
├── components
│ ├── Intro.vue
│ └── README.md
├── data
│ └── profile.json
├── favicon.png
├── layouts
│ ├── Default.vue
│ └── README.md
├── main.js
├── pages
│ ├── About.vue
│ ├── Index.vue
│ └── README.md
├── templates
│ ├── README.md
│ └── Work.vue
└── vendor
└── bootstrap.min.css
这是我的package.json
:
{
"name": "portfolio.farzinnasiri.com",
"version": "0.0.2",
"private": true,
"scripts": {
"build": "gridsome build",
"develop": "gridsome develop",
"explore": "gridsome explore"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-brands-svg-icons": "^5.13.0",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@fortawesome/vue-fontawesome": "^0.1.9",
"@gridsome/source-filesystem": "^0.6.2",
"@gridsome/transformer-remark": "^0.5.0",
"gridsome": "^0.7.0"
}
}
我真的不知道问题出在哪里,需要帮助来解决它。谢谢你的时间