test 发表于 2020-1-22 11:32:19

修复crmeb轮播图1张的情况下点击推荐产品轮播图不切换bug

第一种方法:修改后端
1.文件路径:/app/api/controller/store/StoreProductController.php
2.修改detail(Request $request, $id, $type = 0)方法
3.添加一下代码目的使轮播图数量多几张(建议在110行后面添加)      //sssi判断轮播图==1的时候使轮播图数量达到5个
      if(count($storeInfo['slider_image']) == 1){
            for ($i=1; $i < 5 ; $i++) {
                $storeInfo['slider_image'][$i] = $storeInfo['slider_image'];
            }
      }

第二种方法:修改前端(推荐)
computed: mapGetters(["isLogin"]),
watch: {
    $route(n) {
      if (n.name === NAME) {
      this.id = n.params.id;
      this.storeInfo.slider_image = [];
      this.productCon();
      }
    }
},
updated() {},
mounted: function() {
    document.addEventListener("scroll", this.onScroll, false);
    this.id = this.$route.params.id;
    this.storeInfo.slider_image = [];
    this.productCon();
    this.coupons();
    window.addEventListener("scroll", this.handleScroll);
},
分别在this.id = n.params.id下方新增this.storeInfo.slider_image = [];
和this.id = this.$route.params.id;下方新增this.storeInfo.slider_image = [];

页: [1]
查看完整版本: 修复crmeb轮播图1张的情况下点击推荐产品轮播图不切换bug