拦截被拒绝
请求被拦截has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is
//vue前端请求
axios.get('http://localhost:8181/role/findAllbyPage/1/2').then(function (resp) {
console.log(resp)
//后端
@CrossOrigin //添加注解
public class RoeHandler {...}
table展示
初始化页面
created() {
const _this = this
axios.get('http://localhost:8181/role/findAllbyPage/1/2').then(function (resp) {
console.log(resp)
_this.tableData = resp.data.content
_this.total = resp.data.totalElements
})
}
页面
<el-pagination
background
layout="prev, pager, next"
:total="total"
page-size=2
@current-change="page">
</el-pagination>
函数
page(currentPage){
// alert(currentPage)
const _this = this
axios.get('http://localhost:8181/role/findAllbyPage/'+currentPage+'/2').then(function (resp) {
console.log(resp)
_this.tableData = resp.data.content
_this.total = resp.data.totalElements
})
}
数据
data() {
return {
total: null,
tableData: []
}