tomuwhu

Mélységi bejárás

Sep 26th, 2019
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.     <div id=id>
  3.     <button @click="mb(1)">Bejár</button>
  4.     {{ mj }}
  5.     </div>
  6. </template>
  7.  
  8. <script>
  9. let g=[
  10.     [],
  11.     [2,3],
  12.     [4],
  13.     [4,5],
  14.     [],
  15.     [],
  16.     [5]
  17. ]
  18.  
  19. export default {
  20.     data: () => ({
  21.         mj: Array(7).fill(false)
  22.     }),
  23.     methods: {
  24.         mb(p) {
  25.             this.$set(this.mj,p,true);
  26.             g[p].forEach( v => {
  27.                 if (!this.mj[v]) {
  28.                     this.mb(v)
  29.                 }
  30.             })
  31.         }
  32.     }
  33. }
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment