报错:request:fail Failed to execute 'open' on 'XMLHttpRequest': Invalid URL


```typescript //打包取到的标识 const NODE_ENV = process.env.NODE_ENV; //测试标识 const DEVELOPMENT_ENV = "development"; //正式标识 const PRODUCTION_ENV = "production"; enum Platform { DEV = "DEV", PROD = "PROD", } interface IPlatformType { [keyName: string]: IPlatformItem; } interface IPlatformItem { name: string; readonly url: string; readonly socketUrl: string; } const isPlatform: string = NODE_ENV == DEVELOPMENT_ENV ? Platform.DEV : Platform.PROD; const PlatformType: IPlatformType = { [Platform.DEV]: { name: Platform.DEV, url: "http://127.0.0.1:8086/", socketUrl: "ws://localhost:8086/", }, [Platform.PROD]: { name: Platform.PROD, url: "https://**********/", socketUrl: "wss://**********/", }, }; export default PlatformType[isPlatform]; ``` 在项目出现这个报错主要是Platform.DEV下的url:"http://127.0.0.1:8086/"最后面的(/)漏掉了,导致合成的路径不完整,所以报错:无效的URL


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM