JavaScript 요구 사항 내에서 Intl-Tel-Input 라이브러리에 액세스하는 방법을 찾으려합니다. 나는 다음 코드를 가지고 있으며 타사 코드에 의해 액세스되고 있기 때문에 requireJS 모듈 외부에 콜백이 필요하다.타사에서로드 한 requireJS 패키지의 JavaScript 액세스
callback
함수 내에서 intlTelInput
코드에 액세스하려면 어떻게해야합니까? 내 나뭇 가지 템플릿에서
:
<script type="text/javascript">
require(['crmpicco/details'], function(details) {
details.init();
});
var callback = function (response) {
// I want to access intlTelInput in here
};
</script>
내 config.js
이있다 : 내가 알 수있는 바와 같이
require = {
baseUrl: '/assets/js',
paths: {
'intl-tel-input': '/assets/vendor/intl-tel-input/build/js/intlTelInput.min',
},
shim: {
'intl-tel-input': {
deps: ['libphonenumber-utils']
},
}
};
그들은 UMD를 지원하기 때문에 require ([ 'intl-tel-input'], function (IntlTelInput) {};'콜백 함수를 사용할 수 있다고 생각합니다. 그리고 shimming 필요가 없습니다. – Andrey
@Andrey 구현 방법을 알고 있습니까? 'callback'이'require' 안에 있다면 제 3 자 코드는 콜백 함수를 찾을 수 없습니다. – crmpicco
@Andrey 비슷하게'require'가'callback' 안에 있다면'intlTelInput'을 찾을 수 없습니다. 'TypeError : intlTelInput 함수가 아닙니다'. – crmpicco