我有jQuery范围滑块小部件,我导入和使用如下:
declare var jQuery: any;
import 'jquery-ui/ui/widgets/slider';
import 'jquery-ui/ui/widgets/mouse';
Run Code Online (Sandbox Code Playgroud)
并像这样使用它:
jQuery(this.elementRef.nativeElement).find('#range-slider').slider({..});
Run Code Online (Sandbox Code Playgroud)
我的滑块工作正常.
问题是我需要启用移动触摸的滑块,所以我导入了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';
Run Code Online (Sandbox Code Playgroud)
但它错误:
TypeError: Cannot read property 'prototype' of undefined
Run Code Online (Sandbox Code Playgroud)
显然它无法找到jQuery和jQuery UI.但是,当导入的jQuery不在全局范围内时,如何将jQuery传递给触摸?
我将这个样板用于我的项目.