【问题标题】:SortableJS not working with Onsen UI on desktopSortableJS 无法在桌面上使用 Onsen UI
【发布时间】:2020-08-14 15:07:58
【问题描述】:

只需从Sortable's docs 复制粘贴示例代码。

它在任何触摸屏设备上都可以正常工作,但是一旦我在 Chrome 或任何其他桌面浏览器上查看它,它就会停止工作。没有错误,你不能再拖动了。

Onsen UI 的 JS 可能会覆盖拖动事件或类似的东西,但无法找到解决方案。

【问题讨论】:

    标签: onsen-ui onsen-ui2


    【解决方案1】:

    根据此处给出的答案:https://github.com/SortableJS/Vue.Draggable/issues/508#issuecomment-488314106

    如果有人遇到此问题,那么以下是解决此问题的方法;

    document.body._gestureDetector.dispose()

    如果您出于任何原因需要再次启用它,请使用以下内容

    document.body._gestureDetector = new ons.GestureDetector(document.body);

    由于我的代码在 Vue 组件中使用了 Sortable,因此我最终将其作为 Sortable.create 选项的一部分。它似乎工作得很好:

        onChoose: function(event) {
          if(this.$ons) {
            document?.body?._gestureDetector?.dispose();
          }
        },
        onStart: function(event) {
          if(this.$ons) {
            document?.body?._gestureDetector?.dispose();
          }
        },
        onEnd: (event) => {
          if(this.$ons) {
            document.body._gestureDetector = new this.$ons.GestureDetector(document.body);
          }
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-11
      • 1970-01-01
      • 1970-01-01
      • 2018-01-21
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多