【发布时间】:2018-06-15 05:57:08
【问题描述】:
我正在尝试在我的 vue 组件中导入一个 json 文件,但它给出了这个错误
错误 ./~/buble-loader?{"objectAssign":"Object.assign"}!./~/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/src/App. Vue 未找到模块:错误:无法解析“assets/incomingData.json” '/var/www/html/mac/resources/assets/src'
脚本:
import jsonData from 'assets/incomingData.json'
export default {
name: 'app',
data () {
return {
entryData: jsonData,
outputData: ''
}
},
created () {
this.$store.commit('setEntryData', this.entryData['bundle'])
this.$store.commit('setTargetRate', this.entryData.targetNetRate)
},
beforeMount () {
this.$store.dispatch('calculate').then(res => {
this.outputData = this.$store.getters.getCalculatedData
})
}
}
文件夹结构:
package.json
有什么建议可以解决这个问题吗?
【问题讨论】:
-
将资产移动到
pubilc文件夹并尝试import jsonData from '/assets/incomingData.json' -
App.vue 是否在
store文件夹内? -
@user2486 : 是的
App.vue在存储文件夹中 -
@06011991 你确定吗?看起来不像图片。
-
@06011991 :所以只需使用
import jsonData from 'assets/incomingData.json'进行检查?没有..双点
标签: json import vue.js laravel-5.5