The element frame navigation menu returns to the default when the page is refreshed

Page refresh will initialize the data in data. How to solve this problem?
I tried to execute this.activeIndex = this.$route.name
in the mounted function, but router was loaded on demand and could not get $route
I tried to monitor the route again, but it didn"t work

watch: {
    "$route" (to, from){
      console.log(to);
      this.activeIndex = to.name
    }
  }
 <el-menu 
  :default-active="activeIndex" 
  class="el-menu-demo" 
  mode="horizontal" 
  @select="handleSelect"
  active-text-color="-sharp23b8ff"
  router
>
  <el-menu-item index="/"></el-menu-item>
  <el-menu-item index="publicClass"></el-menu-item>
  <el-menu-item index="specialClass"></el-menu-item>
  <el-menu-item index="me"></el-menu-item>
</el-menu>
export default {
  data() {
    return {
      activeIndex: "/"
    };
  },
  methods: {
    handleSelect(key, keyPath) {
      
    }
  }
}

router.js

import Vue from "vue"
import Router from "vue-router"
import Home from "@/views/Home/Index.vue"


Vue.use(Router)

export default new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/",
      name: "home",
      component: Home
    },
    {
      path: "/publicClass",
      name: "publicClass",
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ "@/views/PublicClass/Index.vue")
    }
  ]
})
Feb.24,2022

el-menu-item index the name, on the page is the name of the route
activeIndex set to the name of the route

export default {
  data() {
    return {
      activeIndex: this.$route.name
    };
  }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ec16-2bbb7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ec16-2bbb7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?