vue 3.0 报错

1,050 阅读1分钟

错误内容

递归调用函数

控制台循环打印

Failed to load http://192.168.1.102:8080/sockjs-node/info?t=1561085655479: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.



网上解答

首先sockjs-node是一个JavaScript库,提供跨浏览器JavaScript的API,创建了一个低延迟,全双工的浏览器和web服务器之间通信通道。
如果你的项目没有用到sockjs,vuecli3 运行npm run serve 之后network里面一直调用一个接口:
http://localhost:8080/sockjs-node/info?t=1556418283950
方案:从根源上关闭此调用
1、node_modules/sockjs-client/dist/sockjs.js
2、代码的1605行注释
// self.xhr.send(payload);

PowerShell 运行 Vue 出错

 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\vue.ps1,
因为在此系统上禁止运行脚本。有关详细信息,请参阅  
https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。


无法加载文件 ******.ps1,因为在此系统中禁止执行脚本。有关详细信息,请参阅 "get-help about_signing"。 
所在位置 行:1 字符: 17 
+ E:\Test\test.ps1 <<<< 
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException 
    + FullyQualifiedErrorId : RuntimeException

 查看“get-help about_signing”:

解决方法

1. 以管理员身份运行PowerShell

2. 执行:get-ExecutionPolicy,回复Restricted,表示状态是禁止的

3.执行:set-ExecutionPolicy RemoteSigned

4.选择Y

注意:一定要以管理员的身份运行PowerShell,不是cmd窗口!

在HBuilder 上的运行Vue 也会此个错误,执行过程一样