首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将javascript翻译为Clojurescript

将javascript翻译为Clojurescript
EN

Stack Overflow用户
提问于 2015-09-07 21:03:36
回答 1查看 643关注 0票数 2

基本上,我对编程很陌生,并被告知从Clojure和Hoplon (其中使用Clojurescript)开始。我试着把谷歌分析代码翻译成文本,我意识到我不知道该怎么做。有人能翻译一下这段代码吗?如果可能的话,我也非常希望能解释一下如何自己解决这个问题。我很感激能在这件事上得到任何帮助。(我已经搜索过了,我发现的只是一些翻译片段,但从来没有全部内容,所以我不知道如何实现。)

代码语言:javascript
复制
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'GOOGLE-ANALYTICS-ID', 'auto');
  ga('send', 'pageview');

</script>

再次感谢你的帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-07 21:28:48

您不需要对代码进行必要的移植(甚至更好)。这里作为一个示例,“今天的learndatalogtoday”项目的一个片段粘贴:

https://github.com/jonase/learndatalogtoday/blob/master/src/clj/learndatalogtoday/views.clj

代码语言:javascript
复制
(def google-analytics-string
  "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-40247950-2', 'learndatalogtoday.org');
  ga('send', 'pageview');")

后来:

代码语言:javascript
复制
  (html5
   [:head
    (include-css "/third-party/bootstrap/css/bootstrap.css")
    (include-css "/style.css")
    [:title "Learn Datalog Today!"]
    [:script google-analytics-string]]
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32446017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档