我想使用ion-range slider
在我的 Angular 项目中。
我创建了名为 ionRangeSlider
的 Angular 指令在我的 Controller 中。
我也在我的项目中使用 requireJS
。
但是当尝试拖动范围时,我遇到了一个错误:e.preventDefault() 未定义?
最佳答案
在源文件中 ion.rangeSlider.Js
替换 e
=>event
并
this.pageX
=> event.pageX
pointerDown: function (target, e) {
event.preventDefault();
var x = event.pageX || event.originalEvent.touches && event.originalEvent.touches[0].pageX;
if (event.button === 2) {
return;
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_active = true;
this.dragging = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = x - this.coords.x_gap;
this.calcPointer();
this.changeLevel(target);
if (is_old_ie) {
$("*").prop("unselectable", true);
}
this.$cache.line.trigger("focus");
this.updateScene();
},
pointerClick: function (target, e) {
event.preventDefault();
var x = event.pageX || event.originalEvent.touches && event.originalEvent.touches[0].pageX;
if (event.button === 2) {
return;
}
this.current_plugin = this.plugin_count;
this.target = target;
this.is_click = true;
this.coords.x_gap = this.$cache.rs.offset().left;
this.coords.x_pointer = +(x - this.coords.x_gap).toFixed();
this.force_redraw = true;
this.calc();
this.$cache.line.trigger("focus");
},
key: function (target, e) {
if (this.current_plugin !== this.plugin_count || event.altKey || event.ctrlKey || event.shiftKey || event.metaKey) {
return;
}
switch (event.which) {
case 83: // W
case 65: // A
case 40: // DOWN
case 37: // LEFT
event.preventDefault();
this.moveByKey(false);
break;
case 87: // S
case 68: // D
case 38: // UP
case 39: // RIGHT
event.preventDefault();
this.moveByKey(true);
break;
}
return true;
},
关于jquery - 在 Angular JS 项目中使用 ionic 范围 slider 抛出 e.preventDefault() 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31702157/