vue路由默认加载问题看能否解决

img

这个应该用什么思路解决,有同学说说用路由重定向,我有的说要用local storage
好像都不行啊

不知道这样可以不可以满足你的需求。

img

img

例:

<template>
  <div class="home">
    {{ msg }}
    <van-button type="primary" @click="switchUrl">主要按钮</van-button>
  </div>
</template>
<script lang="ts">
import { Vue } from "vue-class-component";
export default class Home extends Vue {
  msg = "";
  created() {
    this.msg = this.$route.query.id?.toString() || "-";
  }
  switchUrl() {
    location.href = this.msg == "A" ? "?id=B" : "?id=A";
  }
}
</script>