zoukankan      html  css  js  c++  java
  • Vue连续点击菜单刷新当前页面

    1.跳转代码

                    <template v-for="(kid,index) in child.children" v-if="!kid.hidden">
                      <div :key="kid.name" @click="RoutLink(child,kid,index)">
                        <el-menu-item :index="kid.path" :class="kid">
                          <i class="dise" >●</i>
                          <span v-if="kid.meta&&kid.meta.title">{{ kid.meta.title }}</span>
                        </el-menu-item>
                      </div>
                    </template>

    2,事件代码,我是路径后面加的时间戳,注:在根据路径渲染的文件'"<router-view :key="key"/>",我的项目在AppMain.vue里面如下图:

    <template>
      <div>
        <!-- <transition name="fade-transform" mode="out-in"> -->
        <transition name="el-fade-in-linear">
          <router-view :key="key"/>
        </transition>
      </div>
    </template>
    
    <script>
    export default {
      name: 'AppMain',
      computed: {
        key() {
          return this.$route.name !== undefined ? this.$route.name + +new Date() : this.$route + +new Date()
        }
      }
    }
    </script>
    
    <style scoped>
    </style>
     RoutLink(child, kid, index) {
          const router = this.routes.path + '/' + this.menus.path + '/' + child.path + '/' + kid.path
          this.$router.replace({
            path: router,
            query: {
              t: +new Date() // 保证每次点击路由的query项都是不一样的,确保会重新刷新view
            }
          })
        },
  • 相关阅读:
    乘法逆元
    P1082 同余方程
    数论编程
    倍增LCA模板
    快速幂模板Super
    黑白染色的模板
    暑假提高组集训Day1 T2
    暑假提高组集训Day1 T1
    7月18日刷题记录 二分答案跳石头游戏Getting
    hdu4738(割桥)
  • 原文地址:https://www.cnblogs.com/wangliko/p/11090848.html
Copyright © 2011-2022 走看看