为什么JS设计模式片段不能在sublime中工作

时间:2015-07-02 19:40:18

标签: sublimetext2 code-snippets

以下崇高代码段无效:

<snippet>
    <content><![CDATA[
        (function ($) {
            var defaults = {};

            function NAME(element, options) {
                this.config = $.extend({}, defaults, options);
                this.element = element;
                this.init();
            }

            NAME.prototype.init = function () {
            };

            $.fn.name = function (options) {
                new NAME(this.first(), options);
                return this.first();
            };
        }(jQuery));

]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>jqp</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.js</scope> -->
</snippet>

如果有人可以告诉我如何在代码段中使用自定义参数,那将会很有帮助。

1 个答案:

答案 0 :(得分:0)

$

这应该可以解决问题。 \是一个特殊字符,因此您必须使用${#:PLACEHOLDERNAME}来转义它。此外,我删除了您的额外缩进并添加了制表位以允许自定义参数。您必须使用#表示法为某个单词创建制表位。您可以根据标签停止的顺序将PLACEHOLDERNAME替换为您的号码,并将RewriteEngine On Redirect 301 / https://www.exmaple.org 替换为您希望占位符值表示的任何内容。您可以阅读有关Sublime Text Snippets here的更多信息。