gpt4 book ai didi

clojurescript - 如何使用 ClojureScript 打开新窗口?

转载 作者:行者123 更新时间:2023-12-03 20:46:06 28 4
gpt4 key购买 nike

我需要使用 ClojureScript 打开一个新选项卡。

(js/window.open "http://localhost/go/somewhere")

我收到以下错误:未捕获类型错误:window.open 不是函数

它对设置它没有帮助,因为什么也没有发生,我认为这是因为它是一个函数而不是一个变量。

(set! js/window.open "http://localhost/go/somewhere")

我知道这是可能的,因为我一开始就做对了。我已经忘记自己做了什么。

编辑:也尝试过:

(set! js/window.location.open endpoint)

(set! (js/window.location.open -location) endpoint)

(set! (.. js/window.location.open -location) endpoint)

最佳答案

在尝试使用 set! 时,您不小心“覆盖”了浏览器窗口中的 window.open;所以 window.open 实际上不再是一个可以调用的函数。

在调用 window.open 并重新加载页面之前,请确保没有 set! 调用。您使用 (js/window.open ,,,) 的语法是正确的。

(js/window.open "https://example.com") ; works
(set! js/window.open "https://example.com")
(js/window.open "https://example.com")
; ⇒ TypeError: window.open is not a function

关于clojurescript - 如何使用 ClojureScript 打开新窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58814179/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com