|
@@ -1,14 +1,33 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div>
|
|
<div>
|
|
|
<h1>Demo1</h1>
|
|
<h1>Demo1</h1>
|
|
|
|
|
+ <input type="text" />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { ref, reactive } from "vue";
|
|
|
|
|
-import { useRoute } from "vue-router";
|
|
|
|
|
|
|
+import { ref, reactive, onActivated, onDeactivated } from "vue";
|
|
|
|
|
+import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
-console.log(route);
|
|
|
|
|
|
|
+// console.log(route);
|
|
|
|
|
+// onBeforeRouteLeave((to, from, next) => {
|
|
|
|
|
+// console.log("离开", to);
|
|
|
|
|
+// const token = localStorage.getItem("token");
|
|
|
|
|
+// if (token) next();
|
|
|
|
|
+// });
|
|
|
|
|
+// onBeforeRouteEnter((to, from, next) => {
|
|
|
|
|
+// console.log("进入", to);
|
|
|
|
|
+// next();
|
|
|
|
|
+// });
|
|
|
|
|
+// onBeforeRouteUpdate((to, from, next) => {
|
|
|
|
|
+// console.log("更新", to);
|
|
|
|
|
+// });
|
|
|
|
|
+onActivated(() => {
|
|
|
|
|
+ console.log("组件被激活", "1");
|
|
|
|
|
+});
|
|
|
|
|
+onDeactivated(() => {
|
|
|
|
|
+ console.log("组件失活", "1");
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|