如何使用PureScript获取当前浏览器URL?

huangapple go评论50阅读模式
英文:

How do I get the current browser URL with purescript?

问题

如何在Purescript中获取浏览器的URL,就像在JavaScript中使用 window.location.href 一样?

英文:

How do I get the the browser URL in Purescript, just like when doing window.location.href in javascript?

答案1

得分: 1

import Web.HTML (window)
import Web.HTML.Window (location)
import Web.HTML.Location (pathname)
import Effect.Console (log)

main :: Effect Unit
main = do
l <- window >>= location >>= pathname
log $ l

英文:
import Web.HTML (window)
import Web.HTML.Window (location)
import Web.HTML.Location (pathname)
import Effect.Console (log)



main :: Effect Unit
main = do
  l &lt;- window &gt;&gt;= location &gt;&gt;= pathname
  log $ l

huangapple
  • 本文由 发表于 2023年5月20日 22:04:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76295632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定