我想在我的項目中使用Google的libphonenumber庫。我試圖驗證使用JavaScript版本的電話號碼輸入,但它給了我一個「goog is not defined」的錯誤。我對JavaScript很陌生,我已經花了一天的時間尋找答案,找不到一個答案。錯誤發生在第一行的phonenumberutil.js中,它說libphonenumber:goog沒有定義
goog.provide('i18n.phonenumbers.Error');
這個庫需要關閉圖書館,我將它作爲
<!-- Scripts for google phone number validation utils -->
<tags:script source="/js/GooglePhoneNumberUtils/phonenumberutil.js"/>
<script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"></script>
<script>
goog.require('goog.dom');
goog.require('goog.json');
goog.require('goog.proto2.ObjectSerializer');
goog.require('goog.string.StringBuffer');
</script>
我不知道怎麼回事,所以請任何幫助將是有益的。
如果你不想讓你的用戶下載所有的220千字節他們的網絡瀏覽器,我可以建議你用打火機(70 KB)這個庫的端口:https://github.com/halt-hammerzeit/libphonenumber-js – asdfasdfads 2016-12-02 08:47:11