response设置响应头,解决跨域请求问题,No Access-Control-Allow-Origin header is present on the requested resource
(5条消息)解决浏览器 Provisional headers are shown 无法向后台发送请求问题_qq_15801963的博客-博客blog.csdn.net
先来说自动请求了page问题.
页面中加了
mport {JeecgListMixin} from '@/mixins/JeecgListMixin' export default { name: "ProductTypeModal", mixins: [JeecgListMixin],这个里面混入了页面,create()里有loadData(arg)方法.
可以在自己的页面里重写这个方法.
或者去掉混入,自己写表单的提交.
跨域问题我是:
import axios from 'axios' //加载数据 loadTable() { this.queryParam.pageNo = this.ipagination.current this.queryParam.pageSize = this.ipagination.pageSize var url = this.url.page let that = this # 需要再axios方法外面 axios.defaults.headers['Content-Type'] = 'application/json;charset=UTF-8'; //此处是增加的代码,设置请求头的类型 axios.post(url, { appId: this.appId, pageNumber: this.ipagination.current, pageSize: this.ipagination.pageSize, name: this.queryParam.name, ...//自己的其他参数 }).then(function (res) { console.log('商品类型查询table的结果 = ', res.data.records) if (res.data.records) { that.tableList = res.data.records # axios里面要用that that.ipagination.total = parseInt(res.data.total) } else { that.tableList = []; } }).catch(function (error) { console.log(error); }) },
然后后端的跨域白名单里有localhost:5000端口,
把前端的端口改了一下