【发布时间】:2017-09-26 16:26:23
【问题描述】:
我正在制作一个“在新标签页中打开链接”。我正在使用window.open() 打开新标签。
我的代码:
$scope.doOpenLink = ()->
domain = '127.0.0.1'
port = '3000'
window.open("#{domain}:#{port}");
但我收到此错误:
错误:无法在“窗口”上执行“打开”:无法打开窗口 使用无效的 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' 呈现为 '%3127.0.0.1:3000'。关于如何修复它的任何想法?谢谢
【问题讨论】:
-
代码中
#{}的用途是什么?为什么不;你只是window.open("http://127.0.0.1:3000") -
@JaromandaX 即coffee script string Interpolator
-
哦,对了,没看到代码是coffeescript,还以为是javascript
标签: javascript angularjs coffeescript