Advertisement
tomuwhu

sorrendezős feladat

Feb 18th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.   <div id="app">
  3.     <div id="cim">Rakja sorrendbe a gyümölcsöket a szerint, hogy mennyire szereti (enni)!</div>
  4.     <ol ref="si">
  5.       <li :key="i" v-for="(e,i) in t">{{ e }}</li>
  6.     </ol>
  7.     <ol>
  8.       <li v-for="(elem,i) in mt" :key="i">{{ elem.from }}{{ elem.to }}</li>
  9.     </ol>
  10.   </div>
  11. </template>
  12.  
  13. <script>
  14. import Sortable from "sortablejs";
  15. var mt;
  16. export default {
  17.   name: "cica",
  18.   data() {
  19.     return {
  20.       mt: [],
  21.       t: [
  22.         "narancs",
  23.         "banán",
  24.         "alma",
  25.         "grépfrút",
  26.         "körte",
  27.         "őszibarack",
  28.         "sárgabarck",
  29.         "sárgadinnye",
  30.         "görögdinnye"
  31.       ].sort((a, b) => a.localeCompare(b))
  32.     };
  33.   },
  34.   mounted() {
  35.     mt = this.mt;
  36.     Sortable.create(this.$refs.si, {
  37.       onUpdate(v) {
  38.         mt.push({ from: v.oldIndex + 1, to: v.newIndex + 1 });
  39.       }
  40.     });
  41.   }
  42. };
  43. </script>
  44.  
  45. <style>
  46. body {
  47.   background-color: rgb(210, 238, 236);
  48. }
  49. li {
  50.   cursor: pointer;
  51. }
  52. #cim {
  53.   font-size: 15px;
  54.   text-shadow: 1px 1px 3px black;
  55.   color: rgb(20, 80, 88);
  56. }
  57. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement