问题标签 [google-closure-library]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 检测python中的循环依赖
我不明白为什么类中的_ResolveDependencies
方法DepsTree
可以检测到循环依赖。似乎它可以检测到a
requiresb
和requires的情况e
,但它不是循环依赖。b
e
google-closure-library - Google 的 Closure Javascript 库支持哪些浏览器和设备?
您在哪里可以找到 Google Closure 库是否支持 Android、Safari (iOs) 等?
yui3 - 闭包库或 YUI 3
我正在使用 python、django 构建企业 Web 应用程序。我的最终决定是使用哪个 javascript 库。我正在考虑使用 Google 的闭包库或 YUI3。大部分的开发,我都使用 jQuery。我可以用 jQuery 快速编码,但似乎不适合企业使用。
YUI 3 看起来还不错。它包含了我想使用的大多数小部件,但 Closure 库的功能几乎相同。Closure 库更好的提供是他们有 Closure Compiler,但似乎 Closure 需要编写比 YUI 3 更多的代码。来自 YUI 3 的文档也非常好。
该应用程序将适用于网络和移动设备,因此该库不应在 Android 或 iPhone 等移动设备中中断。
如果你是我,你会做出什么决定?
javascript - 异步延迟 JS 直到满足条件
我有一个类,ChatRoom
它只能在它接收到一个长时间运行的 HTTP 请求后呈现(它可能需要 1 秒或 30 秒)。所以我需要延迟渲染直到ChatRoom.json
不为空。
在下面的代码中,我使用了闭包库的goog.async.ConditionalDelay
. 它可以工作,但是有没有更好的方法(也许不需要闭包库)来做到这一点?
请注意,“while (json == null) { }”是不可能的,因为这将是同步的(阻止所有其他 JS 执行)。
google-closure-compiler - 使用控制台时间
我正在使用 Google Closure Library 及其编译器创建一个应用程序。要调试我使用的值console.log()
。编译它会抛出以下异常JSC_UNDEFINED_VARIABLE. variable console is undeclared at ...
。为了解决这个错误,我只需要window.console.log()
改用。
我还想测量一个函数所花费的时间。Firebug 有两个很好的功能console.time(name)
,并且console.timeEnd(name)
很容易做到这一点。不幸的是,闭包编译器不支持这些函数并抛出以下警告JSC_INEXISTENT_PROPERTY. Property time never defined on Window.prototype.console at ...
。不幸的是,您无法通过添加来解决此警告window
。
我还查看了该库,但 goog.debug.Console 没有我需要的功能。
我之前使用过的另一个解决方案如下
代码有点多,如果你经常使用的话,有两个功能的版本会很棒:
这会打印出开始和结束之间的 MS。但如上所述,这不适用于闭包编译器。window.console.time()
有没有人对此有解决方案,我如何使用这两个功能window.console.timeEnd()
?或者 goog.closure 提供的另一种解决方案,但我还没有找到?
javascript - 使用图像文件创建 goog.ui.Button 的实例
我对 Google Closure 库比较陌生,我目前的障碍是获得一个按钮以编程方式呈现图像(而不是文本)。我尝试添加一个 img 标签作为按钮的内容:
但是,尽管页面中确实呈现了一个空白按钮,但没有出现图像。检查生成的 HTML 会显示一个没有内容的按钮标记。
我还考虑过添加一个样式属性来指定background-image
. 但是,我不清楚如何通过 Button API 完成此操作。
关于如何做到这一点的任何想法或例子?感谢帮助。
编辑:这是我在 Dave Paroulek 的帮助下得出的解决方案:
javascript - Google Closure Compiler - 基于外部的死代码删除
我正在尝试使用 Google Closure Compiler 根据将要运行的位置(在服务器与客户端上)通过单个变量来拆分我的应用程序代码。在此示例中,将在服务器上调用的所有内容都在isServerSide
var 后面,但是,正在为客户端编译代码。所以我将设置isServerSide
为 false 并让编译器删除客户端不会运行的所有内容......
内部app.js
:
内部externs.js
:
命令:
预期输出:
实际输出:
如果我手动输入isServerSide=false;
,app.js
那么我可以将其编译为:
这让我觉得我设置externs.js
错了(或者我只是不明白 externs 应该实际用于什么)。
关于如何使它工作的任何建议?
closures - 使用 Google 闭包库将拖动的元素对齐网格
请,
如何在 Google Closure Library 中制作可拖动元素并对齐网格?
示例:jQueryUI 有选项网格:
$(".selector").draggable({grid: [50, 20]});
google-closure-compiler - What is the correct way to use soyutils with Google Closure?
I am trying to use Google Closure templates (Soy) with Google Closure.
I am including the soyutils_usegoog.js
utilities file as instructed. This file provides a number of utilities used by the generated templates, notably soy.StringBuilder
. Here's how it is creating it:
The soyutils file requires goog.string.StringBuffer
a few lines above, but when running in non-compiled mode this results in a runtime error because the JS file that StringBuffer
resides in will not be loaded until after soyutils has executed.
Unless I am mistaken, JS files in Closure should not immediately access namespaces that they 'require'. The <script>
tag is only added after the execution of the current script (in non-compiled mode) so immediate usage will result in a runtime error.
In short, how can I load in soyutils_usegoog.js
without triggering a runtime error due to the early access of good.string.StringBuffer
.
javascript - 如何让组件上的所有动画能够在完成之前销毁它们?
当我在页面上选择一个元素时,我请求 Json 并使用 和触发页面转换的动画。goog.fx.dom.FadeInAndShow
goog.fx.dom.FadeOutAndHide
如果单击一个元素,然后快速单击另一个元素,则请求将被取消并填充最近一次单击的数据,但是,上一次单击的动画还没有完全完成,这会导致传入信息受先前动画的影响END
。
我想知道getAnimations
组件上是否有类似动画的东西,然后.destroy()
在它们完成之前就可以使用它们。