问题如图,后端代码中已完成
实现WebMvcConfigure接口,重写addCorsMappings方法
@Configuration public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") // .allowedOriginsPatterns("*") .allowCredentials(true) .allowedOrigins("*") .allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS") .allowCredentials(true) .maxAge(3600) .allowedHeaders("*"); } }
项目正常启动,且之前能够实现登录
报错内容指出是跨域问题 但即不是域名不同也不是端口不同(?可能)
尝试前端代码修改方法,失败
6/19更新
上述问题不能算跨域 前端代码设置的...localhost/... 改为...localhost:8080/...后解决了上述报错
现阶段问题
error submit! 但是后端端口测试返回的内容 与data中内容都是代表请求成功 陷入新问题
最终发现是语法错误。。。。。vue2中function()与=>的使用。。。