0

所以我想为以下内容创建一个片段:

$("input").click(function(event){
    //code goes here
});

但是当我尝试在崇高的文本中创建片段时:

<snippet>
    <content><![CDATA[
$("${1:Tag}").click(function(event)
{
    ${2:code goes here}
});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>sclick</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.js</scope>
</snippet>

显然,两者的“$”之间存在某种冲突。我通读了文档,但没有找到任何东西。我如何为此创建一个片段?

4

1 回答 1

2

用于\转义$

<snippet>
    <content><![CDATA[
\$("${1:Tag}").click(function(event)
{
    ${2:code goes here}
});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>sclick</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.js</scope>
</snippet>

(这是唯一支持的转义序列。)

于 2018-07-09T14:01:08.330 回答