【问题标题】:How i can use intl-tel-input jQuery library within ionic 2我如何在 ionic 2 中使用 intl-tel-input jQuery 库
【发布时间】:2017-04-19 21:15:36
【问题描述】:

我如何在ionic 2 中使用这个jQueryhttps://github.com/jackocnr/intl-tel-input

【问题讨论】:

  • 它与ionic2有关,与angular2无关
  • 你尝试了什么?
  • //首先安装 jQuery npm install --save jquery 然后 import * as $ from 'jquery'; 但我的问题是如何在 ioni2 中使用 intl-tel-input

标签: jquery angular typescript ionic2


【解决方案1】:

我使用了名为 intl-tel-input 的第三方库。

1-首先安装jQuery

npm install --save jquery

现在,在任何应用程序文件中导入jquery 就像

import $ from "jquery"; 

它会像这样使用

$('#elemId').width();

2- 安装国际电话输入库

npm install intl-tel-input --save

现在,在任何应用文件中导入 int-tel-input 喜欢

import 'intl-tel-input';

并使用如下:

ngOnInit(): any {
    let telInput = $("#elemtId");
    let output = $("#output");

    telInput.intlTelInput();
    // listen to "keyup", but also "change" to update when the user selects a country
    telInput.on("keyup change", function() {
      var intlNumber = telInput.intlTelInput("getNumber");
      if (intlNumber) {
        output.text("International: " + intlNumber);
      } else {
        output.text("Please enter a number below");
      }
    });
  }

home.html

<p id="output">Please enter a number below</p>
<input id="elemtId" type="tel">

离子信息

您的系统信息:

Cordova CLI: 6.3.1 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: 1.9.0 
ios-sim version: 5.0.8 
OS: OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 7.3 Build version 7D175

【讨论】:

  • 错误 VM1128 vendor.js:52957 错误错误:未捕获(承诺中):TypeError:telInput.intlTelInput 不是函数 TypeError:telInput.intlTelInput 不是函数
猜你喜欢
  • 1970-01-01
  • 2016-01-20
  • 2019-05-11
  • 1970-01-01
  • 2017-08-05
  • 2019-05-28
  • 1970-01-01
  • 1970-01-01
  • 2021-01-03
相关资源
最近更新 更多