Sortable - 图1

Sortable Vue Component

Sortable is not a separate component, but just a particular case of using and components.

Sortable Events

EventDescription
<f7-list> events
The following events will be available on <f7-list> when sortable prop enabled
sortable:enableEvent will be triggered when sortable mode is enabled
sortable:disableEvent will be triggered when sortable mode is disabled
sortable:sortEvent will be triggered after user release currently sorting element in new position. event.detail will contain object with from and to properties with start/new index numbers of sorted list item

Examples

  1. <template>
  2. <f7-page>
  3. <f7-navbar title="Sortable List">
  4. <f7-nav-right>
  5. <f7-link sortable-toggle=".sortable">Toggle</f7-link>
  6. </f7-nav-right>
  7. </f7-navbar>
  8. <f7-block>
  9. <p>Just click "Toggle" button on navigation bar to enable/disable sorting</p>
  10. </f7-block>
  11. <f7-list sortable @sortable:sort="onSort">
  12. <f7-list-item
  13. title="1 Jenna Smith"
  14. after="CEO">
  15. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  16. </f7-list-item>
  17. <f7-list-item
  18. title="2 John Doe"
  19. after="Director">
  20. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  21. </f7-list-item>
  22. <f7-list-item
  23. title="3 John Doe"
  24. after="Developer">
  25. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  26. </f7-list-item>
  27. <f7-list-item
  28. title="4 Aaron Darling"
  29. after="Manager">
  30. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  31. </f7-list-item>
  32. <f7-list-item
  33. title="5 Calvin Johnson"
  34. after="Accounter">
  35. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  36. </f7-list-item>
  37. <f7-list-item
  38. title="6 John Smith"
  39. after="SEO">
  40. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  41. </f7-list-item>
  42. <f7-list-item
  43. title="7 Chloe"
  44. after="Manager">
  45. <f7-icon icon="icon-f7" slot="media"></f7-icon>
  46. </f7-list-item>
  47. </f7-list>
  48. <f7-list media-list sortable @sortable:sort="onSort">
  49. <f7-list-item
  50. title="Yellow Submarine"
  51. after="$15"
  52. subtitle="Beatles"
  53. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  54. >
  55. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-1.jpg" width="80" />
  56. </f7-list-item>
  57. <f7-list-item
  58. title="Don't Stop Me Now"
  59. after="$22"
  60. subtitle="Queen"
  61. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  62. >
  63. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-2.jpg" width="80" />
  64. </f7-list-item>
  65. <f7-list-item
  66. title="Billie Jean"
  67. after="$16"
  68. subtitle="Michael Jackson"
  69. text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sagittis tellus ut turpis condimentum, ut dignissim lacus tincidunt. Cras dolor metus, ultrices condimentum sodales sit amet, pharetra sodales eros. Phasellus vel felis tellus. Mauris rutrum ligula nec dapibus feugiat. In vel dui laoreet, commodo augue id, pulvinar lacus."
  70. >
  71. <img slot="media" src="https://cdn.framework7.io/placeholder/people-160x160-3.jpg" width="80" />
  72. </f7-list-item>
  73. </f7-list>
  74. </f7-page>
  75. </template>
  76. <script>
  77. export default {
  78. methods: {
  79. onSort(e) {
  80. // Sort data
  81. console.log(e.target);
  82. console.log(e.detail);
  83. }
  84. }
  85. };
  86. </script>