如何在 Sublime Text 3 中将此代码用作 JS 的代码段?
How can I use this Code as Snippet for JS in Sublime Text 3?
当我尝试使用时,美元符号阻止代码片段正常工作...
$('.modal').on('hide.bs.modal', function(e) {
var $if = $(e.delegateTarget).find('iframe');
var src = $if.attr("src");
$if.attr("src", '/empty.html');
$if.attr("src", src);
});
您需要使用反斜杠 (\
) 转义美元符号 ($
),同时使用 sublime 文本创建新代码段。您的代码段内容应为:<content>
<snippet>
<content><![CDATA[
$('.modal').on('hide.bs.modal', function(e) {
var $if = $(e.delegateTarget).find('iframe');
var src = $if.attr("src");
$if.attr("src", '/empty.html');
$if.attr("src", src);
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>myscript</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
当我尝试使用时,美元符号阻止代码片段正常工作...
$('.modal').on('hide.bs.modal', function(e) {
var $if = $(e.delegateTarget).find('iframe');
var src = $if.attr("src");
$if.attr("src", '/empty.html');
$if.attr("src", src);
});
您需要使用反斜杠 (\
) 转义美元符号 ($
),同时使用 sublime 文本创建新代码段。您的代码段内容应为:<content>
<snippet>
<content><![CDATA[
$('.modal').on('hide.bs.modal', function(e) {
var $if = $(e.delegateTarget).find('iframe');
var src = $if.attr("src");
$if.attr("src", '/empty.html');
$if.attr("src", src);
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>myscript</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>