Sublime Text 3 - jQuery片段与$ not working

时间:2014-01-02 10:29:50

标签: code-snippets sublimetext3

我写了一个小片段来帮助我在Sublime Text 3中的工作流程:

<snippet>
    <content><![CDATA[
    (function ($) {"use strict";$(function () {$1});}(jQuery));
]]></content>
    Optional: Tab trigger to activate the snippet
    <tabTrigger>self.function</tabTrigger>
    <!-- Optional: Scope the tab trigger will be active in -->
    <scope>source.js</scope>
    <!-- Optional: Description to show in the menu -->
    <description>self.trigger.function</description>
</snippet>

上下文菜单显示是指我开始在javascript文件中输入“self”,但是当我点击“Enter”时,我的文件中没有任何内容。

知道为什么会这样吗?

由于

1 个答案:

答案 0 :(得分:2)

如果您希望字符按字面显示,则需要转义$。否则SublimeText会将其视为可变字段。所以就这样做 -

(function (\$) {"use strict";\$(function () {$1});}(jQuery));

现在它会起作用。详细信息位于content section of the documentation

相关问题