【发布时间】:2019-11-19 13:48:52
【问题描述】:
我尝试在我的项目中获取本地 json 文件。 尝试了以下方法:
import axios from 'axios';
import userDataJson from './../data/userData.json';
export const userDataControllerMixin = {
data() {
return {
users: [],
};
},
mounted() {
this.getUsers();
},
methods: {
getUsers() {
// TODO: load userObj.json initial to prevent reset the userData.json all the time
fetch(userDataJson)
.then((response) => {
console.log(response);
}).catch((err) => {
console.log(err);
});
};
我之前也用 axios 试过,但都导致这个错误消息:
GET http://localhost:9080/[object%20Object] 404 (Not Found)
我做错了什么?看起来是配置问题。
【问题讨论】:
标签: json vue.js electron axios