首页 > 解决方案 > $(...).intercode 不是函数 Phone.js

问题描述

我在我的 Wordpress 网站上使用的名为 Phone.js 的 JS 插件有问题。在我加载了我的 jQuery 之后,我已经包含了脚本。这是我用来触发添加电话字段的代码:

<code><script type="text/javascript">
    jQuery(document).ready(function( $ ) {
    $('.phone').intercode({
    country: 'CA',
    selectClass: 'countryCodeselect left',
    intercodeFile: './js/countrycodes.json'
    });
    });
    </script></code>

这是我在加载页面时收到的错误:

未捕获的类型错误:$(...).intercode 不是函数

这个问题发生在 phone.js 和 intlTelInput.min.js 中,所以它不是特定于一个插件的
任何建议都会很棒!
谢谢

标签: jquerywordpresspluginstypeerrorcompatibility

解决方案


just to answer the question I figured out what was wrong with my integration.
The files were being loaded but in an incorrect order, which was preventing my script from using the loaded plugin functions.
I managed to fix the issue and now the phone field is displaying correctly.
Thanks


推荐阅读