import/export实验-from origin ‘null‘ has been blocked by CORS policy:

1.问题 

Access to script at 'file:///D:/java/tomcat8-ac/webapps/web1/imt.js' 
访问'file:///D:/java/tomcat8-ac/webapps/web1/imt.js'
from origin 'null' has been blocked by CORS policy: 
从原点“null”已被CORS策略阻止:
Cross origin requests are only supported for protocol schemes: 
跨源请求只支持协议方案:
http, data, chrome, chrome-extension, https.

2.原因分析 

从原点“null”已被CORS策略阻止:

为什么被阻止,因为跨源请求不支持file协议。

解决办法:搭建一个http服务器,用支持的协议访问。

3.实验文件

index.html 




import/export实验




 imt.js

// JavaScript Document
export var mian = 5;

import/export实验-from origin ‘null‘ has been blocked by CORS policy:_第1张图片

你可能感兴趣的:(vue)