javascript - JavaScript 中的 $this 是什么?

标签 javascript

我正在查看生成的 JavaScript:

enter image description here

相关代码为

enter image description here

我的问题是,$this指的是什么?只是关键字“this”我理解,但是$this?周围似乎没有任何 jQuery。

感谢您的启发。

最佳答案

这与 Google "jstemplate" 有关机制。

从该页面:

$this: $this refers to the JsEvalContext data object used in processing the current node. So in the above example we could substitute $this.end for end without changing the meaning of the jscontent expression. This may not seem like a very useful thing to do in this case, but there are other cases in which $this is necessary. If the JsEvalContext contains a value such as a string or a number rather than an object with named properties, there is no way to retrieve the value using object-property notation, and so we need $this to access the value.

关于javascript - JavaScript 中的 $this 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20412717/

相关文章:

php - 当使用 JavaScript 在文件字段中未选择要上传的文件时,会弹出警报

javascript - 使用来自外部 API 的传单解析 GeoJSON

javascript - pgwModal:使用触发器选项复制页面中模态内容的 HTML 标记。如何摆脱重复?

javascript - Typescript 功能可将 HTML 音频静音

php - HTML 显示表中数组的数据

javascript - SVG:转换转义的 SVG 字符串并附加到正文不执行任何操作

javascript - 从单个 Intent 输出多个响应

javascript - 与 load() 函数同步代码

javascript - 如何在ckeditor中包装选定的文本

javascript - 根据用户的姓氏创建三个图像