<keep-alive> <component ></component> </keep-alive>缓存的组件实现组件,实现组件切换时每次都执行指定方法

<keep-alive> <component :is="currentRouter" :key="currentRouter"></component> </keep-alive>缓存的组件实现组件切换时子组件每次都执行指定的方法

java 复制代码
// 父组件
 <keep-alive>
        <component :is="currentRouter" :key="currentRouter"></component>
      </keep-alive>

data () {
    return {
        currentRouter: ''
    }

}

components: {
 // 计算维度
    CalculationDimension: () => import('../procurementPlanConfig/calculationDimension.vue'),
    // 价格损失配置
    PriceLossSetting: () => import('../procurementPlanConfig/priceLossSetting.vue')

}

子组件

java 复制代码
  activated () {
    console.log('激活到当前组件时触发')
  },
相关推荐
anOnion8 小时前
构建无障碍组件之Menu Button pattern
前端·html·交互设计
用户47949283569158 小时前
claude Fable用不了?把Gpt 5.5pro接到你的claude code里
前端·后端
zhangxingchao11 小时前
Kotlin常用的Flow 操作符整理
前端
IT_陈寒12 小时前
React的useState居然还有这种坑?我差点删库跑路
前端·人工智能·后端
Pedantic13 小时前
SwiftUI 手势笔记
前端·后端
橙子家14 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
前端
user205855615181314 小时前
X6 中边悬浮置顶,规避 `mouseleave` 事件丢失问题
前端
李明卫杭州14 小时前
CSS aspect-ratio 属性完全指南
前端
Pedantic16 小时前
SwiftUI 手势层级(Gesture Hierarchy)详解
前端