换了src地址,就会报错:Image from origin 'http://bubuol.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:53155' is therefore not allowed access.

原因分析:

image Access-Control-Allow-Origin image Access-Control-Allow-Origin

解决办法:通过设置头信息(Access-Control-Allow-Origin)

C#的config配置
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<system.webServer>
或者response.addHeader("Access-Control-Allow-Origin", "*");// 允许所有的域名
或者response.addHeader("Access-Control-Allow-Origin", "http://camnpr.com");// 允许指定的域名

Canvas Cross initialize Image Test: Testing for Canvas Cross Domain Image CORS Support

Testing...