panmeiyu 3 jaren geleden
bovenliggende
commit
96e06b578f
1 gewijzigde bestanden met toevoegingen van 29 en 4 verwijderingen
  1. 29 4
      src/views/Home.vue

+ 29 - 4
src/views/Home.vue

@@ -143,8 +143,8 @@
                     </ul>
                   </div>
                 </div>
-                <a href="javascript:;" class="preBtn" @click="gotoPre()"></a>
-                <a href="javascript:;" class="nextBtn" @click="gotoNext()"></a>
+                <a href="javascript:;" class="preBtn" @click="gotoPre(item)"></a>
+                <a href="javascript:;" class="nextBtn" @click="gotoNext(item)"></a>
               </div>
             </div>
           </div>
@@ -750,6 +750,7 @@ export default {
       heroData: [
         {
           isboxshow: true,
+          currentgroupsIndex:0,
           herogroups: [
             {
               isshow: true,
@@ -873,6 +874,7 @@ export default {
         },
         {
           isboxshow: false,
+          currentgroupsIndex:0,
           herogroups: [
             {
               isshow: true,
@@ -925,6 +927,7 @@ export default {
         },
         {
           isboxshow: false,
+          currentgroupsIndex:0,
           herogroups: [
             {
               isshow: true,
@@ -1024,8 +1027,30 @@ export default {
       _i.isclick = true;
       this.currentHero = _i.detailImg;
     },
-    gotoPre(){},
-    gotoNext(){},
+    gotoPre(_i){
+      let currentindex = parseInt(_i.currentgroupsIndex) - 1
+      if(currentindex>=0){
+        for(let i of _i.herogroups){
+          i.isshow = false
+        }
+        _i.herogroups[currentindex].isshow = true
+        _i.currentgroupsIndex = currentindex
+      }else{
+        alert("已经是第一页啦~")
+      }
+    },
+    gotoNext(_i){
+      let currentindex = parseInt(_i.currentgroupsIndex) + 1
+      if(currentindex<_i.herogroups.length){
+        for(let i of _i.herogroups){
+          i.isshow = false
+        }
+        _i.herogroups[currentindex].isshow = true
+        _i.currentgroupsIndex = currentindex
+      }else{
+        alert("已经是最后一页啦~")
+      }
+    },
   },
   beforeDestroy() {
     window.removeEventListener("scroll", this.toggleBodyClass);