• vue前台(三)search路径,列表设置过渡效果


    typeNav.vue

    html部分

    <transition name="show">
              <div class="sort" v-show="isShow">
                <div class="all-sort-list2" @click="toSearch">
                  <div
                    class="item"
                    v-for="(c1, index) in categoryList"
                    :key="c1.categoryId"
                    @mouseenter="moveIn(index)"
                    :class="{item_on:currentIndex === index}"
                  >
                    <h3>
                      <a
                        href="javascript:;"
                        :data-category1Id="c1.categoryId"
                        :data-categoryName="c1.categoryName"
                      >{{c1.categoryName}}</a>
                      <!-- 为什么不适用声明式导航,因为一次性创建了多个组件对象影响效率,因此我们采用编程式导航去跳转 -->
                      <!-- <router-link :to="{name:'search',query:{categoryName:c1.categoryName,category1Id:c1.categoryId}}">{{c1.categoryName}}</router-link> -->
                      <!-- 使用了编程式导航,但是效率还不是很高,因为每个类别都添加了相同的点击事件,每个点击事件都有自己的回调函数
                      采用事件委派(事件委托,事件代理)来处理-->
                      <!-- <a href="javascript:;" @click="$router.push({name:'search',query:{categoryName:c1.categoryName,category1Id:c1.categoryId}})">{{c1.categoryName}}</a> -->
                    </h3>
                    <div class="item-list clearfix">
                      <div class="subitem">
                        <dl class="fore" v-for="(c2, index) in c1.categoryChild" :key="c2.categoryId">
                          <dt>
                            <!-- <router-link :to="{name:'search',query:{categoryName:c2.categoryName,category2Id:c2.categoryId}}">{{c2.categoryName}}</router-link> -->
                            <!-- <a href="javascript:;" @click="$router.push({name:'search',query:{categoryName:c2.categoryName,category2Id:c2.categoryId}})">{{c2.categoryName}}</a> -->
    
                            <a
                              href="javascript:;"
                              :data-category2Id="c2.categoryId"
                              :data-categoryName="c2.categoryName"
                            >{{c2.categoryName}}</a>
                          </dt>
                          <dd>
                            <em v-for="(c3, index) in c2.categoryChild" :key="c3.categoryId">
                              <!-- <router-link :to="{name:'search',query:{categoryName:c3.categoryName,category3Id:c3.categoryId}}">{{c3.categoryName}}</router-link> -->
                              <!-- <a href="javascript:;" @click="$router.push({name:'search',query:{categoryName:c3.categoryName,category3Id:c3.categoryId}})">{{c3.categoryName}}</a> -->
                              <a
                                href="javascript:;"
                                :data-category3Id="c3.categoryId"
                                :data-categoryName="c3.categoryName"
                              >{{c3.categoryName}}</a>
                            </em>
                          </dd>
                        </dl>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </transition>

    less部分

      .show-enter{
            height: 0;
            opacity: 0;
        }
    
        .show-enter-to{
            height: 461px;
            opacity: 1;
    
        }
    
        .show-enter-active{
            transition: all 1s;
        }
    
        .show-leave{
             height: 461px;
            opacity: 1;
        }
    
        .show-leave-to{
             height: 0;
            opacity: 0;
        }
    
        .show-leave-active{
            transition: all 1s;
        }
  • 相关阅读:
    Java中的匿名对象、内部类、包、代码块
    Java中的final和static关键字
    Java中的this与super关键字
    Java中的构造方法
    Java中的多态
    Vue+Element中Table懒加载,新增、删除操作后手动更新
    JQ取消hover事件
    github.com访问慢解决
    vue cli3 子目录问题
    右键事件 contextmenu
  • 原文地址:https://www.cnblogs.com/fsg6/p/13320859.html
Copyright © 2020-2023  润新知