| 12345678910111213141516171819202122232425262728293031323334 |
- <template>
- <div>
- <h1>Demo1</h1>
- <input type="text" />
- </div>
- </template>
- <script lang="ts" setup>
- import { ref, reactive, onActivated, onDeactivated } from "vue";
- import { useRoute, onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";
- const route = useRoute();
- // 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>
- <style lang="scss" scoped>
- </style>
|