我正在製作一個「在新標籤頁中打開鏈接」。我正在使用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 –