我正在制作一个“在新标签页中打开链接”。我正在使用window.open()
打开新标签页。未能在'窗口'上执行“打开”:无法打开具有无效网址'%3127.0.0.1:3000'的窗口'
我的代码:
$scope.doOpenLink =()->
domain = '127.0.0.1'
port = '3000'
window.open("#{domain}:#{port}");
,但我得到这个错误:渲染为'%3127.0.0.1:3000'
Error: Failed to execute 'open' on 'Window': Unable to open a window with invalid URL '%3127.0.0.1:3000'.
at MyServerScopeController.vm.doOpenLink (base-adb5b1181b.js:4294) at fn (eval at compile (angular-29115c1a5c.js:15156), <anonymous>:4:286) at callback (angular-29115c1a5c.js:26744) at Scope.$eval (angular-29115c1a5c.js:17972) at Scope.$apply (angular-29115c1a5c.js:18072) at Scope.scopePrototype.$apply (hint.js:1558) at HTMLAnchorElement.<anonymous> (angular-29115c1a5c.js:26749) at HTMLAnchorElement.dispatch (jquery-888d4551b8.js:4737) at HTMLAnchorElement.elemData.handle (jquery-888d4551b8.js:4549)
我的域名'127.0.0.1:3000'
。关于如何修复它的任何想法?由于
你的代码中'#{}'的用途是什么?为什么不会;你只是'window.open(“http://127.0.0.1:3000”)' –
@JaromandaX那是[咖啡脚本字符串插入器](https://coffeescript-cookbook.github.io/chapters/字符串/插值) –
哦,没错,没有看到代码是coffeescript,认为这是javascript –