【问题标题】:How to use requirejs to load jQuery plugin intlTelInput?如何使用requirejs加载jQuery插件intlTelInput?
【发布时间】:2015-02-21 22:38:40
【问题描述】:

有问题的插件是https://github.com/Bluefieldscom/intl-tel-input。所有脚本标签都被requirejs正确插入了,但是我还是不能使用插件intlTelInput

我错过了什么?

require.config({
    baseUrl: "/Scripts/require",
    paths: {
        "jquery": "/Scripts/jquery-2.1.3.min",
        // jquery plugins
        "intlTelInput": "/Scripts/jquery/plugin/intlTelInput-5.3.0.min"
    }
});

define(["jquery", "intlTelInput"], function ($, tel) {
    console.log(tel); // output: undefined
});

【问题讨论】:

    标签: jquery jquery-plugins requirejs amd umd


    【解决方案1】:

    显然,必须通过 jQuery 访问 jQuery 插件。

    require.config({
        baseUrl: "/Scripts/require",
        paths: {
            "jquery": "/Scripts/jquery-2.1.3.min",
            // jquery plugins
            "intlTelInput": "/Scripts/jquery/plugin/intlTelInput-5.3.0.min"
        }
    });
    
    define(["jquery", "intlTelInput"], function ($, tel) {
        console.log($().tel); // now it works
    });
    

    【讨论】:

      猜你喜欢
      • 2012-06-10
      • 2014-08-06
      • 2015-04-21
      • 2015-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-22
      相关资源
      最近更新 更多