这是我的 Vue 组件
<template>
<v-container>
<div id="app">
{{ posts }}
<v-divider></v-divider>
{{status}}
</div>
</v-container>
</template>
<script>
import axios from "axios";
export default {
el: '#app',
data () {
return {
status:null,
posts: []
}
},
mounted () {
axios
.get('http://localhost:8080/uebungen')
.then(response =>{
this.posts=response.data
}
)
}
}
</script>
我想在我的 Spring 程序上发出一个 get 请求,我可以完美地与我的后端一起工作,我可以毫无问题地从 python 或 postman 发送一个 get 请求,但是如果我用 Vue axios 发送一个请求,我会收到这个奇怪的错误在我的浏览器中。
我对 Vue 很陌生,我希望我没有搞砸一些基础知识。
我不会在 vue 或我的 spring 程序中出错,在 vue 中它不会显示任何内容
答案 0 :(得分:0)
这是 cors 错误,出于安全考虑,您的浏览器正在阻止响应。
<块引用>跨源资源共享 (CORS) 是一种标准,允许 服务器放宽同源策略。这用于明确 允许一些跨域请求,同时拒绝其他请求。
可以做什么:
详细了解CORS