今天在学习使用 Layui 数据表格时遇到一个 数据接口请求异常 的问题, Layui 作为一个前端框架,其中的数据都不是从数据库中取到的动态数据,而是写的模拟数据,所以在使用 Layui 时, Layui 的开发者已经为使用者提供了一套 json 数据,我们只需要将数据复制到我们的本地进行使用即可。

正常的数据表格:

解决: Layui 数据表格 数据接口请求异常 Cross origin requests are only supported for protocol schemes: http, data,

数据接口异常:

解决: Layui 数据表格 数据接口请求异常 Cross origin requests are only supported for protocol schemes: http, data,

寻根溯源:

按 F12 会看到如下提示:

解决: Layui 数据表格 数据接口请求异常 Cross origin requests are only supported for protocol schemes: http, data,

原因:这是提示“交叉源请求仅支持协议方案:HTTP、数据、Chrome、Chrome扩展、HTTPS。”
也就是你不能用本地文件打开,本地打开是file:///C:/Users/Acer/Desktop/layui/a.html。

要想是 Http 请求,我们就需要将我们的页面放到服务器上,从而访问到对应的 json 数据。

解决: Layui 数据表格 数据接口请求异常 Cross origin requests are only supported for protocol schemes: http, data,

放到 tomcat 服务器上,就可以完美运行了。

解决: Layui 数据表格 数据接口请求异常 Cross origin requests are only supported for protocol schemes: http, data,

相关文章:

  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2021-12-29
  • 2021-05-09
  • 2022-02-02
  • 2021-05-16
相关资源
相似解决方案