访问本地图片报跨域怎么回事?

访问本地图片报跨域怎么回事?
Access to image at 'file:///C:/Users/1/Desktop/%E6%B0%B4%E6%B3%A2%E7%BA%B9/img/bg2.jpg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
换成线上的也不行 应该怎么办?

body {

color: #fff;

font-size: 16px;

font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;

background-image: url(img/bg2.jpg);

background-size: cover;

background-position: 50% 0;

height: 100%;

text-align: center;

}

回答

本地启sever,用localhost方式访问你网页就正常了。

检查下为啥页面域名和图片域名不一致。提供信息有点少,页面地址和图片地址分别是什么

以上是 访问本地图片报跨域怎么回事? 的全部内容, 来源链接: utcz.com/a/63790.html

回到顶部