新手无法找出其中包含

新手无法找出其中包含

本文介绍了Sublime 新手无法找出其中包含 javascript 的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 sublimeText2,因为 eclipse 对通过 VPN 的大型项目来说真的很慢.我正在尝试带来一些我的片段.大多数工作正常,但以下是我使用的 ajax 调用,但不能作为片段使用.我猜有些字符需要转义或其他什么,但我不确定是哪些

I have just started using sublimeText2 since eclipse is really slow with large projects through a VPN. I am trying to bring over some of my snippets. Most are working ok but the follow one is a ajax call that I use but won't work as a snippet. I am guess that there are characters that need to be escaped or something but I am not sure which ones

<snippet>
    <content><![CDATA[

    $.ajax({
        type: 'get',
        url: '.cfc',
        data: {method:''
            , var: var
            , var2:var
                },
        dataType: 'json',
        async: false,
        success: function(result){
            var result = jQuery.trim(result);
            console.log(result);
            }
        }
    });

]]></content>
    <tabTrigger>ajax</tabTrigger>
</snippet>

谁能看到我哪里出错了?

Can anyone see where I have gone wrong?

推荐答案

必须用 \$ 转义 $ 才有效

Had to escape the $ with \$ and it works

<snippet>
    <content><![CDATA[

    \$.ajax({
        type: 'get',
        url: '.cfc',
        data: {method:''
            , var: var
            , var2:var
                },
        dataType: 'json',
        async: false,
        success: function(result){
            var result = jQuery.trim(result);
            console.log(result);
            }
        }
    });

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

这篇关于Sublime 新手无法找出其中包含 javascript 的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:53