<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('激活到当前组件时触发')
  },
相关推荐
Wect几秒前
深度剖析浏览器跨域问题
前端·面试·浏览器
陈随易14 分钟前
bun将会支持Bun.image,你怎么看?
前端·后端·程序员
Lyyaoo.26 分钟前
缓存更新策略
缓存
jingqingdai331 分钟前
别用正则格式化 HTML!我用 DOM 遍历实现零风险本地格式化,老项目重构效率直接拉满
前端·重构·html
木斯佳34 分钟前
前端八股文面经大全:腾讯前端实习二、三OC面(2026-04-27)·面经深度解析
前端·状态模式
Python私教1 小时前
如意Agent日志系统重构:从 print() 大海捞针到结构化可观测性栈
java·前端·重构
We་ct1 小时前
LeetCode 97. 交错字符串:动态规划详解
前端·算法·leetcode·typescript·动态规划
AI进化营-智能译站1 小时前
ROS2 C++开发系列08-传感器数据缓存与指令解析方式之数组、向量与字符串实战
开发语言·c++·缓存·ai
Chengbei111 小时前
轻量化 Web 安全日志分析神器 星川智盾日志威胁检测、地理溯源、MITRE ATT&CK 映射,支持 Windows/macOS/Linux
前端·人工智能·安全·web安全·macos·系统安全·安全架构