愿所有的美好和期待都能如约而至

如何在Sublime Text 3中将此代码用作JS的代码片段?

发布时间:  来源:互联网  作者:匿名  标签:code-snippets error How can I use this Code as Snippet for JS in Sublime Text 3?  热度:37.5℃

本文介绍了如何在Sublime Text 3中将此代码用作JS的代码片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用时,美元符号阻止代码片段正常工作…

$('.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>

<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>

这篇关于如何在Sublime Text 3中将此代码用作JS的代码片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,

勇敢去编程!

勇敢的热爱编程,未来的你一定会大放异彩,未来的生活一定会因编程更好!

TOP