Ionic Framework: Reorder list error - Uncaught TypeError: Cannot read property ‘getValues’ of null

Ionic Framework: Reorder list error - Uncaught TypeError: Cannot read property ‘getValues’ of null

我正在对教程中的 Todo 应用程序进行改进,但在尝试对列表中的项目重新排序时出现错误。

我认为一切正常,但是当我尝试重新排序项目时,Ionic 出现此错误,并且重新排序不起作用:

未捕获类型错误:无法读取 nullReorderDrag.moveElement 的 属性 'getValues' @ ionic.bundle.js:7429ReorderDrag.start @ionic.bundle.js:7458ionic.views.ListView.ionic.views.View.inherit.startDrag @ionic.bundle.js:7744ionic.views.ListView.ionic.views.View.inherit._handleDrag @ionic.bundle.js:7804(匿名函数) @ionic.bundle.js:7610triggerEvent @ionic.bundle.js:811dragGesture @ionic.bundle.js:1858detect @ionic.bundle.js:1389bindDomOnTouch @ionic.bundle.js:938

我在 Mac OS X Yosemite 中用 Chrome 测试它,使用 "ionic serve"。它在 Android 或 iOS 中均不起作用。

我用应用程序创建了一个 Codepen:http://codepen.io/anon/pen/EjjqPE

这是离子列表部分:

<ion-list show-delete="showDeleteTasks" show-reorder="true">
<ion-item class="item-remove-animate" ng-repeat="task in activeProject.tasks" item="task">
{{task.title}}
<ion-delete-button class="ion-minus-circled" ng-click="deleteTask($index)">
</ion-delete-button>
<ion-reorder-button class="ion-navicon" on-reorder="reorderTask(task, $fromIndex, $toIndex)">
</ion-reorder-button>
</ion-item>
</ion-list>

这里是 JS 文件中的 reorderTask 方法(它被调用,但总是使用相同的 fromIndex 和 toIndex,所以它什么都不做):

$scope.reorderTask = function(task, fromIndex, toIndex) {
console.log("reorderTask llamado");
console.log("Task: " + task);
console.log("fromIndex: " + fromIndex + " - toIndex: " + toIndex);
$scope.activeProject.tasks.splice(fromIndex, 1);
console.log("reorderTask 1");
$scope.activeProject.tasks.splice(toIndex, 0, task);
console.log("reorderTask 2");
Projects.save($scope.projects);
console.log("reorderTask 3");
}

我做错了什么吗?还是 Ionic 错误?

谢谢!

因此,如果您将 <ion-content scroll="false"> 更改为 true,您的问题就会得到解决。 :)

Fix.