在脚本#类中使用一个方法



我有以下类:

[GlobalMethods]
internal static class JQueryTest
{
    static JQueryTest()
    {
        jQuery.OnDocumentReady(delegate
                                   {
                                       test();
                                       test2();
                                   });
    }
    [ScriptName("test")]
    static void test()
    {
        Script.Alert("one");
    }
    [ScriptName("test2")]
    static void test2()
    {
        Script.Alert("two");
    }
}

这将生成以下javascript:

//! Echo.JQueryScript.debug.js
//
(function($) {
Type.registerNamespace('Echo.JQueryScript');
////////////////////////////////////////////////////////////////////////////////
// Echo.JQueryScript._jQueryTest
window.test = function Echo_JQueryScript__jQueryTest$test() {
    alert('one');
}
window.test2 = function Echo_JQueryScript__jQueryTest$test2() {
    alert('two');
}

(function () {
    $(function() {
        test();
        test2();
    });
})();
})(jQuery);
//! This script was generated using Script# v0.7.4.0

这几乎是正确的,我只需要在window.test=…和window.test2=…行的末尾用分号,即:

window.test = function Echo_JQueryScript__jQueryTest$test() {
    alert('one');
};
window.test2 = function Echo_JQueryScript__jQueryTest$test2() {
    alert('two');
};

请其他人告诉我该做什么好吗?

感谢

Stu

我们最终从Script#开始,根据我的经验,它不太支持angularJS。

最新更新