ajax 的 Sublime 片段不起作用 [英] Sublime snippet for ajax not working
本文介绍了ajax 的 Sublime 片段不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个片段,每次我输入 ajax
后按 tab 按钮插入代码,但是当我输入 ajax 并按下 tab 按钮时,它只会删除 ajax
代码片段的文本,我已将其保存为 ajax.sublime-snippet
I am trying to create a snipped that every time I type ajax
follow by the tab button to insert code, but when I type ajax and press the tab button it just deletes the ajax
text for the snippet, I have saved it as ajax.sublime-snippet
我的片段
<snippet>
<content><![CDATA[
$('#${1:binder}').on("", function()
{
$.ajax({
url: ${2:url},
type: ${3:post},
success: function(data)
{
if(!data.success)
{
$('#error_message').html(data.error + alert_close).show();
}else{
$('#success_message').html(data.success + alert_close).show();
}
}
});
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ajax</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
我该如何解决这个问题?
How can I fix this?
推荐答案
转义那些属于代码而不是代码片段的美元符号
Escape those dollar-signs that are part of the code, not of the snippet
<snippet>
<content><![CDATA[
\$('#${1:binder}').on("", function()
{
\$.ajax({
url: ${2:url},
type: ${3:post},
success: function(data)
{
if(!data.success)
{
\$('#error_message').html(data.error + alert_close).show();
}else{
\$('#success_message').html(data.success + alert_close).show();
}
}
});
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>ajax</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
您可能还想取消对范围的注释并将其设置为 source.js
.
You also might want to uncomment the scope and set it to source.js
.
这篇关于ajax 的 Sublime 片段不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文