困扰了很久,找了很多资料,才解决,路由里面的配置都没问题,结果是因为我写组件是直接vue快捷键,没有给组件写name,所以失效
App.vue
<template>
<div id="app">
<keep-alive include="Profile">
<router-view></router-view>
</keep-alive>
<main-tab-bar></main-tab-bar>
</div>
</template>
<template>
<h2>个人</h2>
</template>
<script>
export default {
activated(){
console.log('act in profile');
}
}
</script>
<style>
</style>
怎么试都不ok,加个name
<template>
<h2>个人</h2>
</template>
<script>
export default {
name: "Profile",
activated() {
console.log("act in profile");
},
};
</script>
<style>
</style>
就可以了,我真的是谢了,呜呜呜,麻了