vue2 :
import { getCurrentInstance } from ‘vue’; //获取当前页路由
data() {
return {
currentRouter: ‘’,//默认路由
}
}
const { proxy } = getCurrentInstance();
this.currentRouter = proxy.$router.currentRoute.meta.title
vue3 :
import { useRouter } from ‘vue-router’;
const router = useRouter();
const currentRouter = router.currentRoute.value.meta.title;