我有像这样导入和使用的 jQuery 范围滑块小部件:
declare var jQuery: any;
import 'jquery-ui/ui/widgets/slider';
import 'jquery-ui/ui/widgets/mouse';
并像这样使用它:
jQuery(this.elementRef.nativeElement).find('#range-slider').slider({..});
我的滑块工作正常。
问题是我需要启用移动触摸的滑块,所以我导入了jQuery UI Touch Punch:
declare var jQuery: any;
import 'jquery-ui/ui/widgets/slider';
import 'jquery-ui/ui/widgets/mouse';
import 'jquery-ui-touch-punch';
但它错误:
TypeError: Cannot read property 'prototype' of undefined
显然它找不到jQuery 和 jQuery UI。但是,当导入的 jQuery 不在全局范围内时,如何通过 jQuery 来触摸打孔?
我将这个样板用于我的项目。