我正在尝试使用 axios get 响应从服务器获取 json 数据。
<script>
import axios from 'axios';
export default {
data() {
return {
films: [],
};
},
methods: {
getFilms() {
const path = 'http://localhost:5000/api/v1.0/films';
axios.get(path)
.then((res) => {
this.films = res.data.films;
})
.catch((error) => {
console.error(error);
});
},
},
created() {
this.getFilms();
},
};
</script>
但结果我有空列表。我怎样才能解决这个问题?或者 mb 还有另一种从服务器获取数据的方法。